From 7c89093243504754a8ac5a5cbf646bb5fd252fb2 Mon Sep 17 00:00:00 2001 From: Etienne Kneuss Date: Wed, 13 Feb 2008 16:59:56 +0000 Subject: [PATCH] Fix inconcistencies between substr and substr_compare --- ext/standard/string.c | 9 ++------- ext/standard/tests/strings/substr.phpt | Bin 7098 -> 7322 bytes .../tests/strings/substr_compare.phpt | 7 +++++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index bcb6083cea..43fe859b5f 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -7985,10 +7985,6 @@ PHP_FUNCTION(substr_compare) --len; } - if (len > 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The specified segment exceeds string length"); - RETURN_FALSE; - } } else { end_offset = s1_len; } @@ -8006,14 +8002,13 @@ PHP_FUNCTION(substr_compare) offset = (offset < 0) ? 0 : offset; } - if (offset > s1_len) { + if (offset >= s1_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed initial string length"); RETURN_FALSE; } if (len > s1_len - offset) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The specified segment exceeds string length"); - RETURN_FALSE; + len = s1_len - offset; } cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset))); diff --git a/ext/standard/tests/strings/substr.phpt b/ext/standard/tests/strings/substr.phpt index ffad0110f6c2d136fac0e2f8f13d3c29e8ceaf66..d98fb4e4f1b1f0a2cb270cf00ba7918e3ca5ae5c 100644 GIT binary patch delta 222 zcmdmGKFe~$H;zCqeJzFJlEk7C1sekeH8llY2**w#Cp9m