diff --git a/ext/date/php_date.c b/ext/date/php_date.c index d97dc0825937..d9e4492b1560 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -407,7 +407,6 @@ PHP_RINIT_FUNCTION(date) efree(DATEG(timezone)); } DATEG(timezone) = NULL; - DATEG(tzcache) = NULL; DATEG(last_errors) = NULL; return SUCCESS; @@ -499,6 +498,11 @@ static timelib_tzinfo *php_date_parse_tzfile(const char *formal_tzname, const ti timelib_tzinfo *tzi; int dummy_error_code; + /* Startup memory is released before the first request, so don't cache it */ + if (!EG(active)) { + return timelib_parse_tzfile(formal_tzname, tzdb, &dummy_error_code); + } + if(!DATEG(tzcache)) { ALLOC_HASHTABLE(DATEG(tzcache)); zend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); diff --git a/ext/date/tests/gh25388.phpt b/ext/date/tests/gh25388.phpt new file mode 100644 index 000000000000..84dcdda15658 --- /dev/null +++ b/ext/date/tests/gh25388.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-25388 (Invalid access or leak of startup data for ext/date after early usage (php_log_err in minit+rinit)) +--CREDITS-- +bwoebi +--INI-- +allow_url_include=1 +log_errors=1 +error_log={PWD}/gh25388.log +output_handler=inexistent +date.timezone=Europe/Berlin +--FILE-- + +--CLEAN-- + +--EXPECT-- +Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 + +Warning: PHP Request Startup: function "inexistent" not found or invalid function name in Unknown on line 0 +Europe/Berlin