bug69864.phpt 1.1 KB

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