From: Dmitry Stogov Date: Thu, 24 Aug 2006 09:42:35 +0000 (+0000) Subject: Fixed bug #38315 (Constructing in the destructor causes weird behaviour) X-Git-Tag: RELEASE_1_2_2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c42b3bf689389ae0f22448183c77dc96c7114bd2;p=php Fixed bug #38315 (Constructing in the destructor causes weird behaviour) --- diff --git a/NEWS b/NEWS index 5b464025da..5a4fb6df23 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ PHP NEWS (Ilia) - Fixed bug #38488 (Access to "php://stdin" and family crashes PHP on win32). (Dmitry) +- Fixed bug #38315 (Constructing in the destructor causes weird behaviour). + (Dmitry) - Fixed bug #38265 (heap corruption). (Dmitry) - Fixed PECL bug #8112 (OCI8 persistent connections misbehave when Apache process times out). (Tony) diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 806a5d6f88..e5e127f0f5 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -571,15 +571,6 @@ static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p) Bucket *retval; HANDLE_BLOCK_INTERRUPTIONS(); - - if (ht->pDestructor) { - ht->pDestructor(p->pData); - } - if (p->pData != &p->pDataPtr) { - pefree(p->pData, ht->persistent); - } - retval = p->pListNext; - if (p->pLast) { p->pLast->pNext = p->pNext; } else { @@ -608,9 +599,17 @@ static Bucket *zend_hash_apply_deleter(HashTable *ht, Bucket *p) if (ht->pInternalPointer == p) { ht->pInternalPointer = p->pListNext; } - pefree(p, ht->persistent); - HANDLE_UNBLOCK_INTERRUPTIONS(); ht->nNumOfElements--; + HANDLE_UNBLOCK_INTERRUPTIONS(); + + if (ht->pDestructor) { + ht->pDestructor(p->pData); + } + if (p->pData != &p->pDataPtr) { + pefree(p->pData, ht->persistent); + } + retval = p->pListNext; + pefree(p, ht->persistent); return retval; }