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:
26
Zend/tests/type_declarations/typed_properties_106.phpt
Normal file
26
Zend/tests/type_declarations/typed_properties_106.phpt
Normal 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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user