Fix leak in typed reference assignment

We're only creating tmp here to compare against the existing
coerced_value. We need to destroy it in all cases.
This commit is contained in:
Nikita Popov 2020-08-27 14:36:12 +02:00
parent e701146070
commit a2bbd8f01f
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,22 @@
--TEST--
Do not leak when assigning to reference set with multiple typed properties with type coercion
--FILE--
<?php
class Test {
public string $x;
public string $y;
}
$test = new Test;
$ref = "";
$test->x =& $ref;
$test->y =& $ref;
$val = 42;
$ref = $val;
var_dump($ref, $val);
?>
--EXPECT--
string(2) "42"
int(42)

View File

@ -3133,6 +3133,7 @@ type_error:
zval_ptr_dtor(&tmp);
goto conflicting_coercion_error;
}
zval_ptr_dtor(&tmp);
}
} else {
if (!first_prop) {