SimpleDateFormat::adoptCalendar leak calendarToAdopt upon error

Description

The return in "if (U_FAILURE(status))" of SimpleDateFormat::adoptCalendar leak calendarToAdopt

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 void SimpleDateFormat::adoptCalendar(Calendar* calendarToAdopt) { UErrorCode status = U_ZERO_ERROR; Locale calLocale(fLocale); calLocale.setKeywordValue("calendar", calendarToAdopt->getType(), status); DateFormatSymbols *newSymbols = DateFormatSymbols::createForLocale(calLocale, status); if (U_FAILURE(status)) { return; } DateFormat::adoptCalendar(calendarToAdopt); delete fSymbols; fSymbols = newSymbols; initializeDefaultCentury(); // we need a new century (possibly) }

this is discovered by ASAN when we try to fix a chrome bug in https://logs.chromium.org/logs/v8/buildbucket/cr-buildbucket.appspot.com/8904022980095859248/+/steps/Check/0/logs/regress-997401/0

We should call delete calendarToAdopt before the return.

Status

Assignee

Frank Yung-Fong Tang

Reporter

Frank Yung-Fong Tang

Labels

None

Reviewer

None

Time Needed

Hours

Start date

None

Components

Fix versions

Priority

medium