stas Sun May 31 21:29:54 2009 UTC
Modified files:
/php-src/ext/date php_date.c php_date.h
Log:
fix for #48247
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.235&r2=1.236&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.235 php-src/ext/date/php_date.c:1.236
--- php-src/ext/date/php_date.c:1.235 Wed May 20 08:18:07 2009
+++ php-src/ext/date/php_date.c Sun May 31 21:29:54 2009
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.235 2009/05/20 08:18:07 kalle Exp $ */
+/* $Id: php_date.c,v 1.236 2009/05/31 21:29:54 stas Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -597,6 +597,7 @@
{
date_globals->default_timezone = NULL;
date_globals->timezone = NULL;
+ date_globals->tzcache = NULL;
}
/* }}} */
@@ -615,7 +616,7 @@
efree(DATEG(timezone));
}
DATEG(timezone) = NULL;
- zend_hash_init(&DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0);
+ DATEG(tzcache) = NULL;
return SUCCESS;
}
@@ -628,8 +629,11 @@
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;
}
/* }}} */
@@ -811,13 +815,18 @@
{
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 @@
{
char *tz;
timelib_tzinfo *tzi;
-
+
tz = guess_timezone(DATE_TIMEZONEDB TSRMLS_CC);
tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB TSRMLS_CC);
if (! tzi) {
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.h?r1=1.45&r2=1.46&diff_format=u
Index: php-src/ext/date/php_date.h
diff -u php-src/ext/date/php_date.h:1.45 php-src/ext/date/php_date.h:1.46
--- php-src/ext/date/php_date.h:1.45 Sun May 3 19:57:35 2009
+++ php-src/ext/date/php_date.h Sun May 31 21:29:54 2009
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.h,v 1.45 2009/05/03 19:57:35 derick Exp $ */
+/* $Id: php_date.h,v 1.46 2009/05/31 21:29:54 stas Exp $ */
#ifndef PHP_DATE_H
#define PHP_DATE_H
@@ -153,7 +153,7 @@
ZEND_BEGIN_MODULE_GLOBALS(date)
char *default_timezone;
char *timezone;
- HashTable tzcache;
+ HashTable *tzcache;
timelib_error_container *last_errors;
ZEND_END_MODULE_GLOBALS(date)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php