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