Skip to content

Fix Calendar::createInstance double-free of the adopted TimeZone - #23320

Merged
iliaal merged 1 commit into
php:masterfrom
iliaal:fix/intl-cal-create-df
Oct 5, 2026
Merged

iliaal merged 1 commit into
php:masterfrom
iliaal:fix/intl-cal-create-df

Conversation

@iliaal

@iliaal iliaal commented Aug 16, 2026

Copy link
Copy Markdown
Member

ICU 57+ Calendar::createInstance adopts the TimeZone and frees it if the calendar cannot be created. createInstance and fromDateTime deleted that pointer again on failure.

@@ -0,0 +1,24 @@
--TEST--

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is kinda of useless, I would suggest to drop it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped.

@iliaal
iliaal force-pushed the fix/intl-cal-create-df branch from 7779d19 to 909fb3b Compare August 17, 2026 11:46
@iliaal
iliaal requested a review from devnexen August 17, 2026 11:47

@LamentXU123 LamentXU123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems safe :)

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.
@iliaal
iliaal force-pushed the fix/intl-cal-create-df branch from 909fb3b to 61cfda4 Compare October 5, 2026 11:06
@iliaal
iliaal merged commit 4270414 into php:master Oct 5, 2026
16 of 18 checks passed
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