From 4e831236f88f63b3da96e8164577e36f1dd0bbf2 Mon Sep 17 00:00:00 2001 From: Nora Dossche <7771979+ndossche@users.noreply.github.com> Date: Mon, 2 Mar 2026 18:51:29 +0100 Subject: [PATCH] Fix pcre leak test (#21327) We need an uninterned string to trigger the leak. The loop is also unnecessary. --- ext/pcre/tests/preg_match_frameless_leak.phpt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 @@ Memory leak in preg_match() frameless function with invalid regex and object arg 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 @@ class Str { $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"; ?>