1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix leak in assign_ref with function

As far as I can see, the retval copying is already done in all
callers of this function, so it should not be duplicated here.
This commit is contained in:
Nikita Popov
2019-12-18 17:18:10 +01:00
parent 4a61d842e7
commit df08d6bffe
2 changed files with 23 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
--TEST--
Assigning the result of a non-reference function by-reference should not leak
--FILE--
<?php
function func() {
return [0];
}
$x = $y =& func();
var_dump($x, $y);
?>
--EXPECTF--
Notice: Only variables should be assigned by reference in %s on line %d
array(1) {
[0]=>
int(0)
}
array(1) {
[0]=>
int(0)
}

View File

@@ -596,9 +596,6 @@ static zend_never_inline ZEND_COLD int zend_wrong_assign_to_variable_reference(z
Z_TRY_ADDREF_P(value_ptr);
value_ptr = zend_assign_to_variable(variable_ptr, value_ptr, IS_TMP_VAR, EX_USES_STRICT_TYPES());
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
ZVAL_COPY(EX_VAR(opline->result.var), value_ptr);
}
return 1;
}