php-src/ext/spl/tests/observer_010.phpt
Tyson Andre cdb7aafc23 Fix memory leak(null coalescing operator with Spl hash)
The SEPARATE_ARG_IF_REF macro increased the refcount of the object passed as a
key.
However, when the key did not exist in the ArrayAccess implementation,
the code returned early without trying to decrement the refcount.

Add a test of `??` succeeding+failing on a SplObjectStorage instance.
2016-11-20 15:46:13 -08:00

16 lines
351 B
PHP

--TEST--
SPL: SplObjectStorage null coalescing operator memory leak
--FILE--
<?php
// In maintainer zts mode, this should no longer
// detect memory leaks for the objects
$a = new stdClass();
$b = new stdClass();
$map = new SplObjectStorage();
$map[$a] = 'foo';
var_dump($map[$b] ?? null);
var_dump($map[$a] ?? null);
--EXPECTF--
NULL
string(3) "foo"