[VarDumper] Keep a ref to objects to ensure their handle cannot be reused while cloning

This commit is contained in:
Nicolas Grekas 2019-02-22 21:50:28 +01:00
parent 848a83078c
commit 29a0683107
1 changed files with 2 additions and 0 deletions

View File

@ -33,6 +33,7 @@ class VarCloner extends AbstractCloner
$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 @@ class VarCloner extends AbstractCloner
}
if (empty($objRefs[$h])) {
$objRefs[$h] = $stub;
$objects[] = $v;
} else {
$stub = $objRefs[$h];
++$stub->refCount;