forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix phpGH-17122: memory leak in regex
Because the subpattern names are persistent, and the fact that the symbol table destruction is skipped when using fast_shutdown, this means the refcounts will not be updated for the destruction of the arrays that hold the subpattern name keys. To solve this, detect this situation and duplicate the strings.
- Loading branch information
Showing
2 changed files
with
76 additions
and
4 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,30 @@ | ||
--TEST-- | ||
GH-17122 (memory leak in regex) | ||
--FILE-- | ||
<?php | ||
preg_match('|(?P<name>)(\d+)|', 0xffffffff, $m1); | ||
var_dump($m1); | ||
\preg_match('|(?P<name2>)(\d+)|', 0, $m2); | ||
var_dump($m2); | ||
?> | ||
--EXPECT-- | ||
array(4) { | ||
[0]=> | ||
string(10) "4294967295" | ||
["name"]=> | ||
string(0) "" | ||
[1]=> | ||
string(0) "" | ||
[2]=> | ||
string(10) "4294967295" | ||
} | ||
array(4) { | ||
[0]=> | ||
string(1) "0" | ||
["name2"]=> | ||
string(0) "" | ||
[1]=> | ||
string(0) "" | ||
[2]=> | ||
string(1) "0" | ||
} |