Skip to content

Commit 5875bf7

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Always remove HT iterators, even for uninit HT
2 parents 2c182a7 + 2c508c4 commit 5875bf7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
HT iterator should be destroyed if array becomes empty during array_splice
3+
--FILE--
4+
<?php
5+
$a=[4];
6+
$i = 0;
7+
foreach ($a as &$r) {
8+
var_dump($r);
9+
$a = array_splice($a, 0);
10+
if (++$i == 2) break;
11+
}
12+
?>
13+
--EXPECT--
14+
int(4)
15+
int(4)

Zend/zend_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,10 +1655,10 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
16551655
} else if (EXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) {
16561656
goto free_ht;
16571657
}
1658-
zend_hash_iterators_remove(ht);
16591658
SET_INCONSISTENT(HT_DESTROYED);
16601659
efree(HT_GET_DATA_ADDR(ht));
16611660
free_ht:
1661+
zend_hash_iterators_remove(ht);
16621662
FREE_HASHTABLE(ht);
16631663
}
16641664

0 commit comments

Comments
 (0)