bug79241.phpt 773 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. Bug #79241: Segmentation fault on preg_match()
  3. --FILE--
  4. <?php
  5. // if "’" string is used directly without json_decode,
  6. // the issue does not reproduce
  7. $text = json_decode('"’"');
  8. $pattern = '/\b/u';
  9. // it has to be exact two calls to preg_match(),
  10. // with the second call offsetting after the tick symbol
  11. var_dump(preg_match($pattern, $text, $matches, 0, 0));
  12. var_dump(preg_match($pattern, $text, $matches, 0, 1));
  13. var_dump(preg_last_error() == PREG_BAD_UTF8_OFFSET_ERROR);
  14. echo "\n";
  15. $text = "VA\xff"; $text .= "LID";
  16. var_dump(preg_match($pattern, $text, $matches, 0, 4));
  17. var_dump(preg_match($pattern, $text, $matches, 0, 0));
  18. var_dump(preg_last_error() == PREG_BAD_UTF8_ERROR);
  19. ?>
  20. --EXPECT--
  21. int(0)
  22. bool(false)
  23. bool(true)
  24. int(1)
  25. bool(false)
  26. bool(true)