Skip to content

[intl] Fix leak of time zone wrapper in Calendar debug info - #23503

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/cal-getdebuginfo-tz-leak-84
Open

[intl] Fix leak of time zone wrapper in Calendar debug info#23503
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/cal-getdebuginfo-tz-leak-84

Conversation

@iliaal

@iliaal iliaal commented Aug 29, 2026

Copy link
Copy Markdown
Member

Calendar_get_debug_info() created a temporary IntlTimeZone wrapper zval via
timezone_object_construct() and never released it, leaking one wrapper object
per var_dump()/debug dump of an IntlCalendar instance. The wrapper is now
released with zval_ptr_dtor() after its debug info has been copied into the
result. Other timezone_object_construct() call sites write into return_value
and are refcount-managed. No other intl get_debug_info handler constructs a
temporary wrapper.

@devnexen

devnexen commented Aug 29, 2026

Copy link
Copy Markdown
Member

can we add the following test ?

$cal = IntlCalendar::createInstance('UTC');
ob_start(); var_dump($cal); ob_end_clean();

$o = new stdClass; $before = spl_object_id($o); unset($o);
for ($i = 0; $i < 10; $i++) {
    ob_start();
    var_dump($cal);
    ob_end_clean();
}
$o = new stdClass; $after = spl_object_id($o);

var_dump($after - $before); -> should be 0

Calendar_get_debug_info() built a temporary IntlTimeZone wrapper zval
via timezone_object_construct() and never released it, leaking one
wrapper object per var_dump()/debug dump of an IntlCalendar. Release
the wrapper with zval_ptr_dtor() after its debug info has been copied.
Sibling audit: all other timezone_object_construct() call sites write
into return_value and are refcount-managed; no other intl get_debug_info
handler constructs temporary wrapper objects.
@iliaal
iliaal force-pushed the fix/cal-getdebuginfo-tz-leak-84 branch from 69dacd6 to 928b2ae Compare August 29, 2026 14:47
@iliaal

iliaal commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants