From: Dmitry Stogov Date: Thu, 24 Aug 2006 09:42:51 +0000 (+0000) Subject: Fixed bug #38315 (Constructing in the destructor causes weird behaviour) X-Git-Tag: RELEASE_1_0_0RC1~1896 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6832a5389888fa70ad3216238944d6c8d23f0549;p=php Fixed bug #38315 (Constructing in the destructor causes weird behaviour) --- diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 80ab3d5298..3e0c07390a 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -660,15 +660,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 { @@ -697,9 +688,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; }