Skip to content

Commit 0d44f2b

Browse files
authored
Update mbstring.c
1 parent e614fa2 commit 0d44f2b

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
@@ -2710,9 +2710,18 @@ PHP_FUNCTION(mb_str_ends)
27102710
RETURN_BOOL(0);
27112711
}
27122712

2713-
n = mbfl_strpos(&haystack, &needle, haystack.len-needle.len, 0);
2714-
if (!mbfl_is_error(n)) {
2713+
mbfl_string haystack_tail;
2714+
haystack_tail.encoding = haystack.encoding;
2715+
haystack_tail.no_language = haystack.no_language;
2716+
unsigned char* haystack_tail_val = haystack.val + sizeof(char) * (haystack.len - needle.len);
2717+
haystack_tail.val = haystack_tail_val;
2718+
haystack_tail.len = needle.len;
2719+
2720+
n = mbfl_strpos(&haystack_tail, &needle, 0, 0);
2721+
if (!mbfl_is_error(n) && n == 0) {
27152722
RETURN_BOOL(1);
2723+
} else if (!mbfl_is_error(n)) {
2724+
RETURN_BOOL(0);
27162725
} else {
27172726
switch (-n) {
27182727
case 1:

0 commit comments

Comments
 (0)