Skip to content

Commit e28e414

Browse files
committed
Fixed a bug in zend_memnistr
1 parent ef91794 commit e28e414

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Zend/zend_operators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ zend_memnistr(const char *haystack, const char *needle, size_t needle_len, const
945945
const char *p_upper = NULL;
946946
if (first_lower != first_upper) {
947947
// If the needle length is 1 we don't need to look beyond p_lower as it is a guaranteed match
948-
size_t upper_search_length = end - (needle_len == 1 && p_lower != NULL ? p_lower : haystack);
948+
size_t upper_search_length = needle_len == 1 && p_lower != NULL ? end - haystack : p_lower - haystack;
949949
p_upper = (const char *)memchr(haystack, first_upper, upper_search_length);
950950
}
951951
const char *p = !p_upper || (p_lower && p_lower < p_upper) ? p_lower : p_upper;

0 commit comments

Comments
 (0)