-
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.
Allocate temporary PCRE match data using ZMM
Create a separate general context that uses ZMM as allocator and use it to allocate temporary PCRE match data (there is still one global match data). There is no requirement that the match data and the compiled regex / match context use the same general context. This makes sure that we do not leak persistent memory on bailout and fixes oss-fuzz #25296, on which half the libfuzzer runs currently get stuck.
- Loading branch information
Showing
3 changed files
with
49 additions
and
11 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
18 changes: 18 additions & 0 deletions
18
ext/pcre/tests/preg_replace_callback_fatal_error_leak.phpt
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,18 @@ | ||
--TEST-- | ||
preg_replace_callback() should not leak persistent memory on fatal error | ||
--FILE-- | ||
<?php | ||
|
||
function test() {} | ||
|
||
preg_replace_callback('/a/', function($matches) { | ||
preg_replace_callback('/x/', function($matches) { | ||
function test() {} // Trigger a fatal error. | ||
return 'y'; | ||
}, 'x'); | ||
return 'b'; | ||
}, 'a'); | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Cannot redeclare test() (previously declared in %s on line %d |