Skip to content
Permalink
Browse files

bug #30350 [VarDumper] Keep a ref to objects to ensure their handle c…

…annot 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
  • Loading branch information...
fabpot committed Feb 23, 2019
2 parents 9e4ff87 + 29a0683 commit 83fec23d615324b4ea8471f36175e65570531f02
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/Symfony/Component/VarDumper/Cloner/VarCloner.php
@@ -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;
@@ -200,6 +201,7 @@ protected function doClone($var)
}
if (empty($objRefs[$h])) {
$objRefs[$h] = $stub;
$objects[] = $v;
} else {
$stub = $objRefs[$h];
++$stub->refCount;

0 comments on commit 83fec23

Please sign in to comment.
You can’t perform that action at this time.