xref: /PHP-8.2/ext/mbstring/tests/gh16360.phpt (revision c34d4fbb)
1--TEST--
2GH-16320 mb_substr overflow from negative length
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7try {
8	mb_substr("abcd", PHP_INT_MIN, 4, "UTF-8");
9} catch (\ValueError $e) {
10	echo $e->getMessage() . PHP_EOL;
11}
12try {
13	mb_substr("abcd", 0, PHP_INT_MIN, "UTF-8");
14} catch (\ValueError $e) {
15	echo $e->getMessage() . PHP_EOL;
16}
17var_dump(mb_substr("abcd", PHP_INT_MAX, PHP_INT_MAX, "UTF-8"));
18?>
19--EXPECTF--
20mb_substr(): Argument #2 ($start) must be between %s and %s
21mb_substr(): Argument #3 ($length) must be between %s and %s
22string(0) ""
23
24