Commit 4e831236f88 for php.net
commit 4e831236f88f63b3da96e8164577e36f1dd0bbf2
Author: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Date: Mon Mar 2 18:51:29 2026 +0100
Fix pcre leak test (#21327)
We need an uninterned string to trigger the leak. The loop is also
unnecessary.
diff --git a/ext/pcre/tests/preg_match_frameless_leak.phpt b/ext/pcre/tests/preg_match_frameless_leak.phpt
index 52bbfeceee0..b97cb86347f 100644
--- a/ext/pcre/tests/preg_match_frameless_leak.phpt
+++ b/ext/pcre/tests/preg_match_frameless_leak.phpt
@@ -5,7 +5,7 @@
class Str {
private $val;
public function __construct($val) {
- $this->val = $val;
+ $this->val = str_repeat($val, random_int(1, 1));
}
public function __toString() {
return $this->val;
@@ -15,10 +15,7 @@ public function __toString() {
$regex = new Str("invalid regex");
$subject = new Str("some subject");
-// Running in a loop to ensure leak detection if run with memory tools
-for ($i = 0; $i < 100; $i++) {
- @preg_match($regex, $subject);
-}
+@preg_match($regex, $subject);
echo "Done";
?>