Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83fec23

Browse files
committed
bug #30350 [VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Fixes the root issue that led to #30311 (comment) Commits ------- 29a0683 [VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning
2 parents 9e4ff87 + 29a0683 commit 83fec23

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)