mirror of
https://github.com/php/php-src.git
synced 2024-12-19 15:00:15 +08:00
fd30c59e04
SEND_UNPACK on iterators was duplicating references in-place, which effectively leaks the original value and causes an off-by-one refcount on the duplicated value. Replace this with a deref, as an actual duplication is not even needed in this case.
19 lines
303 B
PHP
19 lines
303 B
PHP
--TEST--
|
|
Bug #75786: segfault when using spread operator on generator passed by reference
|
|
--FILE--
|
|
<?php
|
|
|
|
function &gen($items) {
|
|
foreach ($items as $key => &$value) {
|
|
yield $key => $value;
|
|
}
|
|
}
|
|
|
|
var_dump(...gen(['a', 'b', 'c']));
|
|
|
|
?>
|
|
--EXPECT--
|
|
string(1) "a"
|
|
string(1) "b"
|
|
string(1) "c"
|