From: Nikita Popov Date: Thu, 5 May 2016 12:57:32 +0000 (+0200) Subject: Don't HT_ASSERT rc=1 in zend_hash_apply functions X-Git-Tag: php-7.1.0alpha1~170 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6d4a9e2d29fe201acdcc13f1c0b39e9bdd15163;p=php Don't HT_ASSERT rc=1 in zend_hash_apply functions These are not necessarily used to modify the hash. Move the assert into the APPLY_REMOVE branch only. --- diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 1e3a9aa69a..95652d598d 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -1525,7 +1525,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_fu int result; IS_CONSISTENT(ht); - HT_ASSERT(GC_REFCOUNT(ht) == 1); HASH_PROTECT_RECURSION(ht); for (idx = 0; idx < ht->nNumUsed; idx++) { @@ -1534,6 +1533,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_fu result = apply_func(&p->val); if (result & ZEND_HASH_APPLY_REMOVE) { + HT_ASSERT(GC_REFCOUNT(ht) == 1); _zend_hash_del_el(ht, HT_IDX_TO_HASH(idx), p); } if (result & ZEND_HASH_APPLY_STOP) { @@ -1551,7 +1551,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_f int result; IS_CONSISTENT(ht); - HT_ASSERT(GC_REFCOUNT(ht) == 1); HASH_PROTECT_RECURSION(ht); for (idx = 0; idx < ht->nNumUsed; idx++) { @@ -1560,6 +1559,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_f result = apply_func(&p->val, argument); if (result & ZEND_HASH_APPLY_REMOVE) { + HT_ASSERT(GC_REFCOUNT(ht) == 1); _zend_hash_del_el(ht, HT_IDX_TO_HASH(idx), p); } if (result & ZEND_HASH_APPLY_STOP) { @@ -1579,7 +1579,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_arguments(HashTable *ht, apply_ int result; IS_CONSISTENT(ht); - HT_ASSERT(GC_REFCOUNT(ht) == 1); HASH_PROTECT_RECURSION(ht); @@ -1593,6 +1592,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_arguments(HashTable *ht, apply_ result = apply_func(&p->val, num_args, args, &hash_key); if (result & ZEND_HASH_APPLY_REMOVE) { + HT_ASSERT(GC_REFCOUNT(ht) == 1); _zend_hash_del_el(ht, HT_IDX_TO_HASH(idx), p); } if (result & ZEND_HASH_APPLY_STOP) { @@ -1613,7 +1613,6 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t int result; IS_CONSISTENT(ht); - HT_ASSERT(GC_REFCOUNT(ht) == 1); HASH_PROTECT_RECURSION(ht); idx = ht->nNumUsed; @@ -1625,6 +1624,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t result = apply_func(&p->val); if (result & ZEND_HASH_APPLY_REMOVE) { + HT_ASSERT(GC_REFCOUNT(ht) == 1); _zend_hash_del_el(ht, HT_IDX_TO_HASH(idx), p); } if (result & ZEND_HASH_APPLY_STOP) {