Skip to content

Commit 6408fb2

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Added negative offset test for mb_strrpos Fix segfault in mb_strrpos/mb_strripos with ASCII encoding and negative offset
2 parents 0600f51 + c5a623b commit 6408fb2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/mbstring/tests/gh11217.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-11217: Segfault in mb_strrpos/mb_strripos with ASCII encoding and negative offset
3+
--EXTENSIONS--
4+
mbstring
5+
--FILE--
6+
<?php
7+
var_dump(mb_strrpos('foo', 'foo', -1, 'ASCII'));
8+
var_dump(mb_strripos('foo', 'foo', -1, 'ASCII'));
9+
?>
10+
--EXPECT--
11+
int(0)
12+
int(0)

ext/mbstring/tests/mb_strrpos_basic.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ var_dump(mb_strrpos($string_ascii, 'is', 4, 'ISO-8859-1'));
2222
echo "\n-- ASCII string 2 --\n";
2323
var_dump(mb_strrpos($string_ascii, 'hello, world'));
2424

25+
echo "\n-- ASCII string with negative offset --\n";
26+
var_dump(mb_strrpos($string_ascii, 'hello', -1, 'ISO-8859-1'));
27+
2528
echo "\n-- Multibyte string 1 --\n";
2629
$needle1 = base64_decode('44CC');
2730
var_dump(mb_strrpos($string_mb, $needle1));
@@ -41,6 +44,9 @@ int(15)
4144
-- ASCII string 2 --
4245
bool(false)
4346

47+
-- ASCII string with negative offset --
48+
bool(false)
49+
4450
-- Multibyte string 1 --
4551
int(20)
4652

0 commit comments

Comments
 (0)