[date] Free timelib_time when get_timezone_info() fails in php_mktime/php_strftime - #300
Open
iliaal wants to merge 1 commit into
Open
[date] Free timelib_time when get_timezone_info() fails in php_mktime/php_strftime#300iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
…/php_strftime php_mktime() and php_strftime() called timelib_time_ctor() before the get_timezone_info() lookup and early-returned on failure without a dtor, leaking the timelib_time when the timezone database is corrupt. Move the ctor after the successful lookup so no allocation precedes the failure return; the gmt paths keep their original ordering. Siblings audited: all other get_timezone_info() call sites construct timelib_time only after the NULL check or free unconditionally on their path.
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.
php_mktime() and php_strftime() allocated a timelib_time with timelib_time_ctor() before calling get_timezone_info() and early-returned without freeing it when the timezone database is corrupt, leaking the structure. This moves the constructor call after the successful timezone lookup so no allocation precedes the failure return; behaviour on all reachable paths is unchanged. Not userland-reproducible without a corrupt tzdb, so this ships as a fix-only change.