xref: /PHP-8.2/ext/pcre/tests/bug81243.phpt (revision a6b43086)
1--TEST--
2Bug #81243 (Too much memory is allocated for preg_replace())
3--FILE--
4<?php
5$test_string = str_repeat('Eins zwei drei', 2000);
6
7$replaced = preg_replace('/\s/', '-', $test_string);
8$mem0 = memory_get_usage();
9$replaced = str_repeat($replaced, 1);
10$mem1 = memory_get_usage();
11var_dump($mem0 == $mem1);
12
13$replaced = preg_replace_callback('/\s/', function ($_) {return '-';}, $test_string);
14$mem0 = memory_get_usage();
15$replaced = str_repeat($replaced, 1);
16$mem1 = memory_get_usage();
17var_dump($mem0 == $mem1);
18?>
19--EXPECT--
20bool(true)
21bool(true)
22