diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-28 09:32:18 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-08-28 09:32:18 +0200 |
commit | 937d5f6598036d48713e28bf68df52cd56e1c974 (patch) | |
tree | e1d4c11b05509810d96de920add6fdc3838289f4 | |
parent | 8cefd7c5ce5ccba7024dedf9da1b3743896fce2a (diff) | |
download | php-git-937d5f6598036d48713e28bf68df52cd56e1c974.tar.gz |
Compute needle end only after checking it's non-empty
-rw-r--r-- | Zend/zend_operators.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index b42ad7f395..ef88dfb584 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -148,7 +148,6 @@ static zend_always_inline const char * zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const char *end) { const char *p = haystack; - const char ne = needle[needle_len-1]; ptrdiff_t off_p; size_t off_s; @@ -168,6 +167,7 @@ zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const } if (EXPECTED(off_s < 1024 || needle_len < 9)) { /* glibc memchr is faster when needle is too short */ + const char ne = needle[needle_len-1]; end -= needle_len; while (p <= end) { @@ -210,7 +210,6 @@ static zend_always_inline const char * zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const char *end) { const char *p = end; - const char ne = needle[needle_len-1]; ptrdiff_t off_p; size_t off_s; @@ -230,6 +229,7 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const } if (EXPECTED(off_s < 1024 || needle_len < 3)) { + const char ne = needle[needle_len-1]; p -= needle_len; do { |