From: Andrei Zmievski Date: Mon, 6 Nov 2000 19:41:30 +0000 (+0000) Subject: Fix bug #7667. X-Git-Tag: php-4.0.4RC3~299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65f37060db5c93cdff0b307a2544688393d0143f;p=php Fix bug #7667. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index be54fde2de..f6452abd85 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1270,7 +1270,9 @@ PHP_FUNCTION(substr_replace) if (f < 0) { f = 0; } - } + } else if (f > (int)(*str)->value.str.len) + f = (int)(*str)->value.str.len; + /* if "length" position is negative, set it to the length * needed to stop that many chars from the end of the string @@ -1282,10 +1284,6 @@ PHP_FUNCTION(substr_replace) } } - if (f >= (int)(*str)->value.str.len) { - RETURN_STRINGL((*str)->value.str.val, (*str)->value.str.len, 1); - } - if((f+l) > (int)(*str)->value.str.len) { l = (int)(*str)->value.str.len - f; }