1
0
mirror of https://github.com/php/php-src.git synced 2026-04-05 15:12:39 +02:00
Files
archived-php-src/ext/standard/tests/serialize/SplObjectStorage_object_reference.phpt
Nikita Popov d29d3a4bf6 Fix use-after-scope in SplObjectStorage::unserialize()
Introduced by the recent switch to a zend_object. Unserialize the
object into a tmp_var to avoid leaving behind a stack reference.

Fixes oss-fuzz #29271.
2021-01-05 12:44:17 +01:00

34 lines
578 B
PHP

--TEST--
Reference to SplObjectStorage key (not supported)
--FILE--
<?php
$inner = 'x:i:1;O:8:"stdClass":0:{};m:a:0:{}';
$inner_len = strlen($inner);
$str = <<<STR
a:2:{i:0;C:16:"SPlObjectStorage":{$inner_len}:{{$inner}}i:1;R:4;}
STR;
var_dump(unserialize($str));
?>
--EXPECTF--
array(2) {
[0]=>
object(SplObjectStorage)#1 (1) {
["storage":"SplObjectStorage":private]=>
array(1) {
["%s"]=>
array(2) {
["obj"]=>
object(stdClass)#2 (0) {
}
["inf"]=>
NULL
}
}
}
[1]=>
object(stdClass)#2 (0) {
}
}