To avoid decrementing a null pointer lateron. As we need to check
for NULL here anayway, we should take the chance to bail out right
away.
p -= needle_len;
do {
- if ((p = (const char *)zend_memrchr(haystack, *needle, (p - haystack) + 1)) && ne == p[needle_len-1]) {
- if (!memcmp(needle + 1, p + 1, needle_len - 2)) {
- return p;
- }
+ p = (const char *)zend_memrchr(haystack, *needle, (p - haystack) + 1);
+ if (!p) {
+ return NULL;
+ }
+ if (ne == p[needle_len-1] && !memcmp(needle + 1, p + 1, needle_len - 2)) {
+ return p;
}
} while (p-- >= haystack);