]> granicus.if.org Git - php/commitdiff
return false instead of empty string when -length is greater than (len - offset)
authorAntony Dovgal <tony2001@php.net>
Mon, 12 Mar 2007 23:42:26 +0000 (23:42 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 12 Mar 2007 23:42:26 +0000 (23:42 +0000)
ext/standard/string.c

index 7e32ba33f53059d5f6eb28b0d9d003d8ce76ccad..86738ff4ac61f62983441c443615e1330fb4eead 100644 (file)
@@ -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
         */