xref: /PHP-8.2/ext/pcre/tests/gh16189.phpt (revision f453d1ae)
1--TEST--
2GH-16189 (preg_match/preg_match_all underflow on start_offset argument)
3--FILE--
4<?php
5
6try {
7	preg_match( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches, 0, PHP_INT_MIN);
8} catch (\ValueError $e) {
9	echo $e->getMessage() . PHP_EOL;
10}
11try {
12	preg_match_all( '/<(\w+)[\s\w\-]+ id="S44_i89ew">/', '<br><div id="S44_i89ew">', $matches, 0, PHP_INT_MIN);
13} catch (\ValueError $e) {
14	echo $e->getMessage() . PHP_EOL;
15}
16?>
17--EXPECTF--
18preg_match(): Argument #5 ($offset) must be greater than %s
19preg_match_all(): Argument #5 ($offset) must be greater than %s
20