Skip to content

Commit 29a0683

Browse files
[VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning
1 parent 848a830 commit 29a0683

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Symfony/Component/VarDumper/Cloner/VarCloner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ protected function doClone($var)
3333
$indexedArrays = []; // Map of queue indexes that hold numerically indexed arrays
3434
$hardRefs = []; // Map of original zval hashes to stub objects
3535
$objRefs = []; // Map of original object handles to their stub object counterpart
36+
$objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning
3637
$resRefs = []; // Map of original resource handles to their stub object counterpart
3738
$values = []; // Map of stub objects' hashes to original values
3839
$maxItems = $this->maxItems;
@@ -200,6 +201,7 @@ protected function doClone($var)
200201
}
201202
if (empty($objRefs[$h])) {
202203
$objRefs[$h] = $stub;
204+
$objects[] = $v;
203205
} else {
204206
$stub = $objRefs[$h];
205207
++$stub->refCount;

0 commit comments

Comments
 (0)