Skip to content

Commit ecf368b

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #79792
2 parents b48bd67 + 48a2471 commit ecf368b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Zend/tests/bug79792.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #79792: HT iterators not removed if empty array is destroyed
3+
--FILE--
4+
<?php
5+
$a = [42];
6+
foreach ($a as &$c) {
7+
// Make the array empty.
8+
unset($a[0]);
9+
// Destroy the array.
10+
$a = null;
11+
}
12+
?>
13+
===DONE===
14+
--EXPECTF--
15+
Warning: foreach() argument must be of type array|object, null given in %s on line %d
16+
===DONE===

Zend/zend_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,11 +1652,11 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
16521652
}
16531653
} while (++p != end);
16541654
}
1655-
zend_hash_iterators_remove(ht);
1656-
SET_INCONSISTENT(HT_DESTROYED);
16571655
} else if (EXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) {
16581656
goto free_ht;
16591657
}
1658+
zend_hash_iterators_remove(ht);
1659+
SET_INCONSISTENT(HT_DESTROYED);
16601660
efree(HT_GET_DATA_ADDR(ht));
16611661
free_ht:
16621662
FREE_HASHTABLE(ht);

0 commit comments

Comments
 (0)