1
0
mirror of https://github.com/php/php-src.git synced 2026-04-16 12:31:06 +02:00

Merge branch 'PHP-7.4'

* PHP-7.4:
  Fix const/cv freeing on failed reference assignment
This commit is contained in:
Nikita Popov
2019-12-18 09:54:18 +01:00
2 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
--TEST--
CONST/CV should not be freed on failed reference assignment
--FILE--
<?php
class Test {
public ?Type $prop;
}
$obj = new Test;
$ref =& $obj->prop;
try {
$ref = [1];
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$ary = [1];
$ref = $ary;
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
var_dump($ref);
?>
--EXPECT--
Cannot assign array to reference held by property Test::$prop of type ?Type
Cannot assign array to reference held by property Test::$prop of type ?Type
NULL

View File

@@ -3155,7 +3155,9 @@ ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_uc
Z_TRY_DELREF_P(value);
}
if (!ret) {
zval_ptr_dtor(value);
if (value_type & (IS_VAR|IS_TMP_VAR)) {
zval_ptr_dtor(value);
}
return Z_REFVAL_P(variable_ptr);
}