diff options
-rw-r--r-- | ext/standard/string.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index 4ce916715a..a59115765f 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1767,13 +1767,18 @@ PHP_FUNCTION(strrpos) } if (offset >= 0) { + if (offset > haystack_len) { + RETURN_FALSE; + } p = haystack + offset; e = haystack + haystack_len - needle_len; } else { - p = haystack; if (-offset > haystack_len) { - e = haystack - needle_len; - } else if (needle_len > -offset) { + RETURN_FALSE; + } + + p = haystack; + if (needle_len > -offset) { e = haystack + haystack_len - needle_len; } else { e = haystack + haystack_len + offset; |