Skip to content

Commit 3cd491e

Browse files
committed
Fix IntlGregorianCalendar double-free of an adopted TimeZone
GregorianCalendar(TimeZone*, ...) adopts the zone in the constructor. On U_FAILURE the calendar destructor already deletes that zone, so the extra delete tz is a double free. 8.5 and master carry the same delete, ahead of the unique_ptr destroying the calendar rather than after it.
1 parent d09e5e2 commit 3cd491e

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fixed a use-after-free when cloning a DOMNameSpaceNode after
1111
DOMDocument::xinclude(). (iliaal)
1212

13+
- Intl:
14+
. Fixed a double-free when IntlGregorianCalendar construction fails after
15+
the ICU constructor adopts the TimeZone. (iliaal)
16+
1317
- Opcache:
1418
. Fixed opcache.protect_memory race under ZTS. (realFlowControl)
1519

ext/intl/calendar/gregoriancalendar_methods.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ static void _php_intlgregcal_constructor_body(
168168
if (gcal) {
169169
delete gcal;
170170
}
171-
delete tz;
172171
if (!is_constructor) {
173172
zval_ptr_dtor(return_value);
174173
RETVAL_NULL();

0 commit comments

Comments
 (0)