mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Fixed bug #77853
This commit is contained in:
parent
eea61cda7d
commit
d7b5954f28
2
NEWS
2
NEWS
@ -32,6 +32,8 @@ PHP NEWS
|
||||
(Vlad Temian)
|
||||
. Fixed bug #77844 (Crash due to null pointer in parse_ini_string with
|
||||
INI_SCANNER_TYPED). (Nikita)
|
||||
. Fixed bug #77853 (Inconsistent substr_compare behaviour with empty
|
||||
haystack). (Nikita)
|
||||
|
||||
04 Apr 2019, PHP 7.2.17
|
||||
|
||||
|
@ -5739,7 +5739,7 @@ PHP_FUNCTION(substr_compare)
|
||||
offset = (offset < 0) ? 0 : offset;
|
||||
}
|
||||
|
||||
if ((size_t)offset >= ZSTR_LEN(s1)) {
|
||||
if ((size_t)offset > ZSTR_LEN(s1)) {
|
||||
php_error_docref(NULL, E_WARNING, "The start position cannot exceed initial string length");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
20
ext/standard/tests/strings/bug77853.phpt
Normal file
20
ext/standard/tests/strings/bug77853.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #77853: Inconsistent substr_compare behaviour with empty haystack
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(substr_compare('', '', 0, 0));
|
||||
var_dump(substr_compare('', '', 0));
|
||||
|
||||
var_dump(substr_compare('abc', '', 3, 0));
|
||||
var_dump(substr_compare('abc', '', 3));
|
||||
|
||||
var_dump(substr_compare('abc', "\0", 3));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(-1)
|
@ -27,9 +27,7 @@ int(0)
|
||||
int(0)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d
|
||||
bool(false)
|
||||
int(-1)
|
||||
bool(true)
|
||||
int(0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user