if (len == 0) {
RETURN_LONG(0L);
} else {
- php_error_docref(NULL, E_WARNING, "The length must be greater than or equal to zero");
- RETURN_FALSE;
+ zend_throw_error(NULL, "The length must be greater than or equal to zero");
+ return;
}
}
Bug #33605 (substr_compare crashes)
--FILE--
<?php
-$res = substr_compare("aa", "a", -99999999, -1, 0);
-var_dump($res);
+try {
+ substr_compare("aa", "a", -99999999, -1, 0);
+} catch (\Error $e) {
+ echo $e->getMessage();
+}
?>
--EXPECTF--
-Warning: substr_compare(): The length must be greater than or equal to zero in %s on line %d
-bool(false)
+The length must be greater than or equal to zero
var_dump(substr_compare("abcde", "abcdef", -10, 10) < 0);
var_dump(substr_compare("abcde", "abc", 0, 0));
echo "Test\n";
-var_dump(substr_compare("abcde", "abc", 0, -1));
+
+try {
+ substr_compare("abcde", "abc", 0, -1);
+} catch (\Error $e) {
+ echo $e->getMessage() . "\n";
+}
var_dump(substr_compare("abcde", "abc", -1, NULL, -5) > 0);
echo "Done\n";
bool(true)
int(0)
Test
-
-Warning: substr_compare(): The length must be greater than or equal to zero in %s on line %d
-bool(false)
+The length must be greater than or equal to zero
bool(true)
Done