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