mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Stale array iterator pointer
This commit is contained in:
1
NEWS
1
NEWS
@@ -7,6 +7,7 @@ PHP NEWS
|
||||
emits a warning. (Girgias)
|
||||
. Fixed bug GH-19637 (Incorrect Closure scope for FCC in constant
|
||||
expression). (timwolla)
|
||||
. Fixed bug GH-19613 (Stale array iterator pointer). (ilutov)
|
||||
|
||||
- Date:
|
||||
. Fixed date_sunrise() and date_sunset() with partial-hour UTC offset.
|
||||
|
||||
22
Zend/tests/gh19613.phpt
Normal file
22
Zend/tests/gh19613.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-19613: Invalidated array iterator pointer after array separation
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = [1];
|
||||
$i = 0;
|
||||
|
||||
foreach ($a as &$v) {
|
||||
$a[0] = $a;
|
||||
foreach ($v as &$w) {
|
||||
$w = $a;
|
||||
|
||||
if ($i++ == 64) {
|
||||
die("===DONE===\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
===DONE===
|
||||
@@ -634,8 +634,15 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval
|
||||
&& EXPECTED(!HT_ITERATORS_OVERFLOW(ht))) {
|
||||
HT_DEC_ITERATORS_COUNT(iter->ht);
|
||||
}
|
||||
SEPARATE_ARRAY(array);
|
||||
ht = Z_ARRVAL_P(array);
|
||||
|
||||
/* Inlined SEPARATE_ARRAY() with updating of iterator when EG(ht_iterators) grows. */
|
||||
if (UNEXPECTED(GC_REFCOUNT(ht) > 1)) {
|
||||
ZVAL_ARR(array, zend_array_dup(ht));
|
||||
GC_TRY_DELREF(ht);
|
||||
iter = EG(ht_iterators) + idx;
|
||||
ht = Z_ARRVAL_P(array);
|
||||
}
|
||||
|
||||
if (EXPECTED(!HT_ITERATORS_OVERFLOW(ht))) {
|
||||
HT_INC_ITERATORS_COUNT(ht);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user