Skip to content

Commit

Permalink
[VarDumper] Keep a ref to objects to ensure their handle cannot be re…
Browse files Browse the repository at this point in the history
…used while cloning
  • Loading branch information
nicolas-grekas committed Feb 22, 2019
1 parent 848a830 commit 29a0683
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/VarDumper/Cloner/VarCloner.php
Expand Up @@ -33,6 +33,7 @@ protected function doClone($var)
$indexedArrays = []; // Map of queue indexes that hold numerically indexed arrays
$hardRefs = []; // Map of original zval hashes to stub objects
$objRefs = []; // Map of original object handles to their stub object counterpart
$objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning
$resRefs = []; // Map of original resource handles to their stub object counterpart
$values = []; // Map of stub objects' hashes to original values
$maxItems = $this->maxItems;
Expand Down Expand Up @@ -200,6 +201,7 @@ protected function doClone($var)
}
if (empty($objRefs[$h])) {
$objRefs[$h] = $stub;
$objects[] = $v;
} else {
$stub = $objRefs[$h];
++$stub->refCount;
Expand Down

0 comments on commit 29a0683

Please sign in to comment.