Skip to content

Commit 61cfda4

Browse files
committed
Fix Calendar::createInstance double-free of the adopted TimeZone
ICU 57+ Calendar::createInstance wraps the TimeZone in a LocalPointer and deletes it when the calendar cannot be created. PHP deleted the same pointer again on that failure. Drop the extra delete in createInstance and fromDateTime.
1 parent 3571d36 commit 61cfda4

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ PHP NEWS
1515
unconstructed Collator. (Ilia Alshanetsky)
1616
. Added optional $availableLocales argument to Locale::acceptFromHttp()
1717
(GH-24074). (David Carlier)
18+
. Fixed a double-free when Calendar::createInstance() or
19+
IntlCalendar::fromDateTime() fails after adopting a TimeZone.
20+
(Ilia Alshanetsky)
1821

1922
- Lexbor:
2023
. Merge patches lexbor/lexbor@8a14bc0 and lexbor/lexbor@f67ce4b, fixing a

‎ext/intl/calendar/calendar_methods.cpp‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(intlcal_create_instance)
9696
Calendar *cal = Calendar::createInstance(timeZone,
9797
Locale::createFromName(locale_str), status);
9898
if (UNEXPECTED(cal == NULL)) {
99-
delete timeZone;
10099
intl_error_set(NULL, status, "Error creating ICU Calendar object");
101100
RETURN_NULL();
102101
}
@@ -1073,7 +1072,6 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(intlcal_from_date_time)
10731072
cal = Calendar::createInstance(timeZone,
10741073
Locale::createFromName(locale_str), status);
10751074
if (UNEXPECTED(cal == NULL)) {
1076-
delete timeZone;
10771075
intl_error_set(NULL, status,
10781076
"error creating ICU Calendar object");
10791077
goto error;

0 commit comments

Comments
 (0)