From 5dc676866f11327fd127ca85dabe8ba71ac6bfc2 Mon Sep 17 00:00:00 2001 From: ndossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:44:13 +0100 Subject: [PATCH] Fix pcre leak test 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 52bbfeceee0d1..b97cb86347fb5 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"; ?>