1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix pcre leak test (#21327)

We need an uninterned string to trigger the leak. The loop is also
unnecessary.
This commit is contained in:
Nora Dossche
2026-03-02 18:51:29 +01:00
committed by GitHub
parent e78f0d149e
commit 4e831236f8

View File

@@ -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";
?>