1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/spl/tests/gh14290.phpt
Niels Dossche b3a56bd558 Fix GH-14290: Member access within null pointer in extension spl
php_pcre_replace_impl() can fail and return NULL. We should take that
error condition into account. Because other failures return false, we
return false here as well.

At first, I also thought there was a potential memory leak in the error
check of replacement_str, but found that the error condition can never
trigger, so replace that with an assertion.

Closes GH-14292.
2024-05-21 23:20:32 +02:00

17 lines
339 B
PHP

--TEST--
GH-14290 (Member access within null pointer in extension spl)
--INI--
pcre.backtrack_limit=2
pcre.jit=0
--FILE--
<?php
$h = new ArrayIterator(['test' => 'test1']);
$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE);
foreach ($i as $name => $value) {
var_dump($name, $value);
}
echo "Done\n";
?>
--EXPECT--
Done