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:
@@ -5,7 +5,7 @@ Memory leak in preg_match() frameless function with invalid regex and object arg
|
|||||||
class Str {
|
class Str {
|
||||||
private $val;
|
private $val;
|
||||||
public function __construct($val) {
|
public function __construct($val) {
|
||||||
$this->val = $val;
|
$this->val = str_repeat($val, random_int(1, 1));
|
||||||
}
|
}
|
||||||
public function __toString() {
|
public function __toString() {
|
||||||
return $this->val;
|
return $this->val;
|
||||||
@@ -15,10 +15,7 @@ class Str {
|
|||||||
$regex = new Str("invalid regex");
|
$regex = new Str("invalid regex");
|
||||||
$subject = new Str("some subject");
|
$subject = new Str("some subject");
|
||||||
|
|
||||||
// Running in a loop to ensure leak detection if run with memory tools
|
@preg_match($regex, $subject);
|
||||||
for ($i = 0; $i < 100; $i++) {
|
|
||||||
@preg_match($regex, $subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Done";
|
echo "Done";
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user