Skip to content

[date] Free timelib_time when get_timezone_info() fails in php_mktime/php_strftime - #300

Open
iliaal wants to merge 1 commit into
masterfrom
fix/date-tzdb-failure-timelib-leak-master
Open

[date] Free timelib_time when get_timezone_info() fails in php_mktime/php_strftime#300
iliaal wants to merge 1 commit into
masterfrom
fix/date-tzdb-failure-timelib-leak-master

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

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.

…/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant