Fix IntlGregorianCalendar double-free of an adopted TimeZone - #23321
Closed
iliaal wants to merge 1 commit into
Closed
Fix IntlGregorianCalendar double-free of an adopted TimeZone#23321iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
iliaal
force-pushed
the
fix/intl-gcal-adopt-df
branch
from
August 16, 2026 16:36
5ca1d40 to
b5943e9
Compare
Contributor
Author
|
Yeah, updated to 8.4 |
LamentXU123
requested changes
Aug 16, 2026
| echo $cal->getType(), "\n"; | ||
|
|
||
| $cal2 = IntlGregorianCalendar::createInstance('UTC', 'en_US'); | ||
| echo $cal2->getTimeZone()->getID(), "\n"; |
Member
There was a problem hiding this comment.
IMO The added test does not exercise the fix.
You see, both constructions succeed, while the removed deletion runs only under U_FAILURE(status). The test produces identical expected output on an affected PHP 8.6.0beta1 build.
See here
Contributor
Author
There was a problem hiding this comment.
Correct. That delete only runs when the ICU constructor sets U_FAILURE, which I could not reach from any locale input, so no .phpt goes red here. Dropped the test. 3cd491e
Member
|
Otherwise this looks good. |
iliaal
force-pushed
the
fix/intl-gcal-adopt-df
branch
from
August 17, 2026 11:31
b5943e9 to
f157891
Compare
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.
iliaal
force-pushed
the
fix/intl-gcal-adopt-df
branch
from
August 17, 2026 11:40
f157891 to
3cd491e
Compare
LamentXU123
approved these changes
Aug 17, 2026
Member
|
Yeah I am surprised that nobody discover this bug.. |
Member
|
Note that in 8.5 and master, we use |
LamentXU123
added a commit
that referenced
this pull request
Aug 17, 2026
* PHP-8.5: Fix IntlGregorianCalendar double-free of an adopted TimeZone (#23321)
pull Bot
pushed a commit
to Ballalhossaintalukder/php-src
that referenced
this pull request
Aug 17, 2026
* PHP-8.4: Fix IntlGregorianCalendar double-free of an adopted TimeZone (php#23321)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The timezone-and-locale IntlGregorianCalendar constructor passes the TimeZone to an adopting ICU constructor. On failure PHP deleted that zone again after delete gcal already ran the calendar destructor.