Skip to content

Commit 1a9def4

Browse files
wkhudgins92Will Hudgins
authored andcommitted
Update mbstring.c
1 parent df0e11c commit 1a9def4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ext/mbstring/mbstring.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,9 +2718,18 @@ PHP_FUNCTION(mb_str_ends)
27182718
RETURN_BOOL(0);
27192719
}
27202720

2721-
n = mbfl_strpos(&haystack, &needle, haystack.len-needle.len, 0);
2722-
if (!mbfl_is_error(n)) {
2721+
mbfl_string haystack_tail;
2722+
haystack_tail.encoding = haystack.encoding;
2723+
haystack_tail.no_language = haystack.no_language;
2724+
unsigned char* haystack_tail_val = haystack.val + sizeof(char) * (haystack.len - needle.len);
2725+
haystack_tail.val = haystack_tail_val;
2726+
haystack_tail.len = needle.len;
2727+
2728+
n = mbfl_strpos(&haystack_tail, &needle, 0, 0);
2729+
if (!mbfl_is_error(n) && n == 0) {
27232730
RETURN_BOOL(1);
2731+
} else if (!mbfl_is_error(n)) {
2732+
RETURN_BOOL(0);
27242733
} else {
27252734
switch (-n) {
27262735
case 1:

0 commit comments

Comments
 (0)