Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44089 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35975 invoked from network); 29 May 2009 01:00:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 May 2009 01:00:12 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.116 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.116 us-gw1.zend.com Windows 2000 SP4, XP SP1 Received: from [63.205.162.116] ([63.205.162.116:35982] helo=us-gw1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/B3-15317-9933F1A4 for ; Thu, 28 May 2009 21:00:10 -0400 Received: from [192.168.16.83] ([192.168.16.83]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 May 2009 18:00:20 -0700 Message-ID: <4A1F3395.8030804@zend.com> Date: Thu, 28 May 2009 18:00:05 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: jani.taskinen@iki.fi CC: Ilia Alshanetsky , PHP Development References: <5FA2019D-A6AE-43A3-93BB-E19D26DC91DE@prohost.org> <4A1DA3B7.7050300@zend.com> <4A1E5428.9030304@sci.fi> In-Reply-To: <4A1E5428.9030304@sci.fi> Content-Type: multipart/mixed; boundary="------------060402000903050003020504" X-OriginalArrivalTime: 29 May 2009 01:00:20.0384 (UTC) FILETIME=[D6B50200:01C9DFF8] Subject: patch for #48247 From: stas@zend.com (Stanislav Malyshev) --------------060402000903050003020504 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi! > No, it's not fixed. Just needs some infinite recursion protection plus > moving the (or rather adding it also) init of tzcache into GINIT. Attached is the patch that seems to do the trick for me. Any objections? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com --------------060402000903050003020504 Content-Type: text/plain; name="date.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="date.diff" Index: php_date.c =================================================================== RCS file: /repository/php-src/ext/date/php_date.c,v retrieving revision 1.43.2.45.2.69 diff -u -r1.43.2.45.2.69 php_date.c --- php_date.c 19 May 2009 15:37:38 -0000 1.43.2.45.2.69 +++ php_date.c 29 May 2009 00:57:34 -0000 @@ -343,6 +343,7 @@ { date_globals->default_timezone = NULL; date_globals->timezone = NULL; + date_globals->tzcache = NULL; } /* }}} */ @@ -361,7 +362,7 @@ efree(DATEG(timezone)); } DATEG(timezone) = NULL; - zend_hash_init(&DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0); + DATEG(tzcache) = NULL; return SUCCESS; } @@ -374,8 +375,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; } /* }}} */ @@ -552,13 +556,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; } @@ -654,7 +663,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) { Index: php_date.h =================================================================== RCS file: /repository/php-src/ext/date/php_date.h,v retrieving revision 1.17.2.11.2.5 diff -u -r1.17.2.11.2.5 php_date.h --- php_date.h 31 Dec 2008 11:17:36 -0000 1.17.2.11.2.5 +++ php_date.h 29 May 2009 00:57:34 -0000 @@ -87,7 +87,7 @@ ZEND_BEGIN_MODULE_GLOBALS(date) char *default_timezone; char *timezone; - HashTable tzcache; + HashTable *tzcache; ZEND_END_MODULE_GLOBALS(date) #ifdef ZTS --------------060402000903050003020504--