mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
b175ea4215
This regressed in cd53ce838a
.
The loop with `zend_hash_iterators_update` hangs forever because
`iter_pos` can't advance to idx. This is because the
`zend_hash_iterators_lower_pos` upper bound is `target->nNumUsed`,
but that is set to `source->nNumOfElements`.
That means that if there are holes in the array, we still loop over all
the buckets but the number of bucket slots will not match.
Fix it by changing the assignment.
Closes GH-12831.
31 lines
428 B
PHP
31 lines
428 B
PHP
--TEST--
|
|
GH-12826 (Weird pointers issue in nested loops)
|
|
--FILE--
|
|
<?php
|
|
$test = array(
|
|
'a' => 1,
|
|
'b' => 2,
|
|
'c' => 3,
|
|
'd' => 4,
|
|
);
|
|
|
|
unset($test['a']);
|
|
unset($test['b']);
|
|
|
|
foreach($test as $k => &$v) { // Mind the reference!
|
|
echo "Pass $k : ";
|
|
|
|
foreach($test as $kk => $vv) {
|
|
echo $test[$kk];
|
|
if ($kk == $k) $test[$kk] = 0;
|
|
}
|
|
|
|
echo "\n";
|
|
}
|
|
|
|
unset($v);
|
|
?>
|
|
--EXPECT--
|
|
Pass c : 34
|
|
Pass d : 04
|