Skip to content

Commit 48a2471

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #79792
2 parents 6a9d934 + 64931fd commit 48a2471

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ PHP NEWS
1717
static variable). (Nikita)
1818
. Fixed bug #79779 (Assertion failure when assigning property of string
1919
offset by reference). (Nikita)
20+
. Fixed bug #79792 (HT iterators not removed if empty array is destroyed).
21+
(Nikita)
2022

2123
- Fileinfo:
2224
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)

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: Invalid argument supplied for foreach() 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
@@ -1627,11 +1627,11 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
16271627
}
16281628
} while (++p != end);
16291629
}
1630-
zend_hash_iterators_remove(ht);
1631-
SET_INCONSISTENT(HT_DESTROYED);
16321630
} else if (EXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) {
16331631
goto free_ht;
16341632
}
1633+
zend_hash_iterators_remove(ht);
1634+
SET_INCONSISTENT(HT_DESTROYED);
16351635
efree(HT_GET_DATA_ADDR(ht));
16361636
free_ht:
16371637
FREE_HASHTABLE(ht);

0 commit comments

Comments
 (0)