-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Zend/tests/type_declarations/typed_properties_reference_coercion_leak.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters