1--TEST-- 2Bug #69864 (Segfault in preg_replace_callback) 3--SKIPIF-- 4<?php 5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 6?> 7--FILE-- 8<?php 9const PREG_CACHE_SIZE = 4096; // this has to be >= the resp. constant in php_pcre.c 10 11var_dump(preg_replace_callback('/a/', function($m) { 12 for ($i = 0; $i < PREG_CACHE_SIZE; $i++) { 13 preg_match('/foo' . $i . 'bar/', '???foo' . $i . 'bar???'); 14 } 15 return 'b'; 16}, 'aa')); 17var_dump(preg_replace_callback('/a/', function($m) { 18 for ($i = 0; $i < PREG_CACHE_SIZE; $i++) { 19 preg_replace('/foo' . $i . 'bar/', 'baz', '???foo' . $i . 'bar???'); 20 } 21 return 'b'; 22}, 'aa')); 23var_dump(preg_replace_callback('/a/', function($m) { 24 for ($i = 0; $i < PREG_CACHE_SIZE; $i++) { 25 preg_split('/foo' . $i . 'bar/', '???foo' . $i . 'bar???'); 26 } 27 return 'b'; 28}, 'aa')); 29var_dump(preg_replace_callback('/a/', function($m) { 30 for ($i = 0; $i < PREG_CACHE_SIZE; $i++) { 31 preg_grep('/foo' . $i . 'bar/', ['???foo' . $i . 'bar???']); 32 } 33 return 'b'; 34}, 'aa')); 35?> 36--EXPECT-- 37string(2) "bb" 38string(2) "bb" 39string(2) "bb" 40string(2) "bb" 41