]> granicus.if.org Git - php/commitdiff
Fixed bug #54454 (substr_compare incorrectly reports equality in some cases)
authorPierrick Charron <pierrick@php.net>
Sun, 3 Apr 2011 07:18:27 +0000 (07:18 +0000)
committerPierrick Charron <pierrick@php.net>
Sun, 3 Apr 2011 07:18:27 +0000 (07:18 +0000)
ext/standard/string.c
ext/standard/tests/strings/bug54454.phpt [new file with mode: 0644]
ext/standard/tests/strings/substr_compare.phpt

index 1aae38ccab2e97632485e5c51647674e74e7a22c..5eb0411b18e33604233514050ea14c5ea9c8b53d 100644 (file)
@@ -5252,10 +5252,6 @@ PHP_FUNCTION(substr_compare)
                RETURN_FALSE;
        }
 
-       if (len > s1_len - offset) {
-               len = s1_len - offset;
-       }
-
        cmp_len = (uint) (len ? len : MAX(s2_len, (s1_len - offset)));
 
        if (!cs) {
diff --git a/ext/standard/tests/strings/bug54454.phpt b/ext/standard/tests/strings/bug54454.phpt
new file mode 100644 (file)
index 0000000..88835c9
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Bug #54454 (substr_compare incorrectly reports equality in some cases)
+--FILE--
+<?php
+var_dump(substr_compare('/', '/asd', 0, 4));
+?>
+--EXPECT--
+int(-3)
index 206ccd5edea0183f99f317d599e40a7f2c7ac943..c647506b53736a7ee244e1e98127aa9f9fccb1ab 100644 (file)
@@ -27,7 +27,7 @@ int(-1)
 
 Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
 bool(false)
-int(0)
+int(-1)
 
 Warning: substr_compare() expects parameter 5 to be boolean, object given in %s on line %d
 bool(false)