-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--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 |