p = haystack + offset;
e = haystack + haystack_len - needle_len;
} else {
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
e = haystack + haystack_len - 1;
} else {
p = haystack;
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");
RETURN_FALSE;
}
p = haystack_dup + offset;
e = haystack_dup + haystack_len - needle_len;
} else {
- if (-offset > haystack_len || offset < -INT_MAX) {
+ if (offset < -INT_MAX || -offset > haystack_len) {
efree(needle_dup);
efree(haystack_dup);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset is greater than the length of haystack string");