diff options
author | Stanislav Malyshev <stas@php.net> | 2009-05-31 21:28:38 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2009-05-31 21:28:38 +0000 |
commit | 2d6377e3224d39d3f6af9f324186b2a94444d05c (patch) | |
tree | cf540c313ac23a09109282e81adf987cf53d5e6c | |
parent | 77beb62c5f70e5c4792a01b299ae40d9ab02227d (diff) | |
download | php-git-2d6377e3224d39d3f6af9f324186b2a94444d05c.tar.gz |
fix for #48247
-rw-r--r-- | ext/date/php_date.c | 21 | ||||
-rw-r--r-- | ext/date/php_date.h | 2 |
2 files changed, 16 insertions, 7 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 35d24430e9..a52188f88b 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -590,6 +590,7 @@ static PHP_GINIT_FUNCTION(date) { date_globals->default_timezone = NULL; date_globals->timezone = NULL; + date_globals->tzcache = NULL; } /* }}} */ @@ -608,7 +609,7 @@ PHP_RINIT_FUNCTION(date) efree(DATEG(timezone)); } DATEG(timezone) = NULL; - zend_hash_init(&DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); + DATEG(tzcache) = NULL; return SUCCESS; } @@ -621,8 +622,11 @@ PHP_RSHUTDOWN_FUNCTION(date) efree(DATEG(timezone)); } DATEG(timezone) = NULL; - zend_hash_destroy(&DATEG(tzcache)); - + if(DATEG(tzcache)) { + zend_hash_destroy(DATEG(tzcache)); + FREE_HASHTABLE(DATEG(tzcache)); + DATEG(tzcache) = NULL; + } return SUCCESS; } /* }}} */ @@ -804,13 +808,18 @@ static timelib_tzinfo *php_date_parse_tzfile(char *formal_tzname, const timelib_ { timelib_tzinfo *tzi, **ptzi; - if (zend_hash_find(&DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void **) &ptzi) == SUCCESS) { + if(!DATEG(tzcache)) { + ALLOC_HASHTABLE(DATEG(tzcache)); + zend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); + } + + if (zend_hash_find(DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void **) &ptzi) == SUCCESS) { return *ptzi; } tzi = timelib_parse_tzfile(formal_tzname, tzdb); if (tzi) { - zend_hash_add(&DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void *) &tzi, sizeof(timelib_tzinfo*), NULL); + zend_hash_add(DATEG(tzcache), formal_tzname, strlen(formal_tzname) + 1, (void *) &tzi, sizeof(timelib_tzinfo*), NULL); } return tzi; } @@ -906,7 +915,7 @@ PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D) { char *tz; timelib_tzinfo *tzi; - + tz = guess_timezone(DATE_TIMEZONEDB TSRMLS_CC); tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB TSRMLS_CC); if (! tzi) { diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 93518a3a6b..a98b2d521a 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -149,7 +149,7 @@ struct _php_period_obj { ZEND_BEGIN_MODULE_GLOBALS(date) char *default_timezone; char *timezone; - HashTable tzcache; + HashTable *tzcache; timelib_error_container *last_errors; ZEND_END_MODULE_GLOBALS(date) |