From 81f99c721b2589134d69c501b9e691a10bac87d0 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Mon, 12 Mar 2007 23:42:26 +0000 Subject: [PATCH] return false instead of empty string when -length is greater than (len - offset) --- ext/standard/string.c | 4 ++++ 1 file changed, 4 insertions(+) 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 */ -- 2.50.1