From: Antony Dovgal Date: Mon, 12 Mar 2007 23:42:26 +0000 (+0000) Subject: return false instead of empty string when -length is greater than (len - offset) X-Git-Tag: php-5.2.2RC1~162 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81f99c721b2589134d69c501b9e691a10bac87d0;p=php return false instead of empty string when -length is greater than (len - offset) --- diff --git a/ext/standard/string.c b/ext/standard/string.c index 7e32ba33f5..86738ff4ac 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2077,6 +2077,10 @@ PHP_FUNCTION(substr) RETURN_FALSE; } + if (l < 0 && (l + Z_STRLEN_PP(str) - f) < 0) { + RETURN_FALSE; + } + /* if "from" position is negative, count start position from the end * of the string */