Commit 850aa02c143 for php.net
commit 850aa02c143e3b6e91ac231d9c3e4bcea0239325
Author: Ilia Alshanetsky <ilia@ilia.ws>
Date: Tue Aug 18 02:40:56 2026 +0800
Fix IntlGregorianCalendar double-free of an adopted TimeZone (#23321)
The timezone-and-locale IntlGregorianCalendar constructor passes the TimeZone
to an adopting ICU constructor. On failure, PHP deleted that zone again after
the calendar destructor had already freed it.
Closes #23321
diff --git a/NEWS b/NEWS
index 338409dd70c..8f462c66a26 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ PHP NEWS
. Fixed a use-after-free when cloning a DOMNameSpaceNode after
DOMDocument::xinclude(). (iliaal)
+- Intl:
+ . Fixed a double-free when IntlGregorianCalendar construction fails after
+ the ICU constructor adopts the TimeZone. (iliaal)
+
- Opcache:
. Fixed opcache.protect_memory race under ZTS. (realFlowControl)
diff --git a/ext/intl/calendar/gregoriancalendar_methods.cpp b/ext/intl/calendar/gregoriancalendar_methods.cpp
index 0b36e621ef7..0725cb4582f 100644
--- a/ext/intl/calendar/gregoriancalendar_methods.cpp
+++ b/ext/intl/calendar/gregoriancalendar_methods.cpp
@@ -168,7 +168,6 @@ static void _php_intlgregcal_constructor_body(
if (gcal) {
delete gcal;
}
- delete tz;
if (!is_constructor) {
zval_ptr_dtor(return_value);
RETVAL_NULL();