summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-06-29 10:27:13 +0200
committerAnatol Belski <ab@php.net>2015-06-29 10:27:42 +0200
commit5060060317b0fd8c8d806c81e673b37ffb830159 (patch)
tree374406a5a47c6b638fcc167acd4eb9153b286763
parent8271890d8dd600a8b91fe41b2996ffdd878e2f6e (diff)
downloadphp-git-5060060317b0fd8c8d806c81e673b37ffb830159.tar.gz
fix negative zend_long to size_t cast
-rw-r--r--ext/standard/string.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 6c5e58e2bb..101e88b6b3 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2484,9 +2484,10 @@ PHP_FUNCTION(substr_replace)
* of the string
*/
if (f < 0) {
- f = Z_STRLEN_P(str) + f;
- if (f < 0) {
+ if (f < 0 && -f > Z_STRLEN_P(str)) {
f = 0;
+ } else {
+ f = Z_STRLEN_P(str) + f;
}
} else if (f > Z_STRLEN_P(str)) {
f = Z_STRLEN_P(str);