mirror of
https://github.com/php/php-src.git
synced 2026-03-28 18:22:42 +01:00
Merge branch 'PHP-7.1'
This commit is contained in:
@@ -5276,10 +5276,10 @@ PHP_FUNCTION(substr_count)
|
||||
|
||||
if (ac == 4) {
|
||||
|
||||
if (length <= 0) {
|
||||
if (length < 0) {
|
||||
length += (haystack_len - offset);
|
||||
}
|
||||
if ((length <= 0) || ((size_t)length > (haystack_len - offset))) {
|
||||
if (length < 0 || ((size_t)length > (haystack_len - offset))) {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid length value");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
12
ext/standard/tests/strings/bug74041.phpt
Normal file
12
ext/standard/tests/strings/bug74041.phpt
Normal file
@@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Bug #74041: substr_count with length=0 broken
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(substr_count("aaa", "a", 0, 0));
|
||||
var_dump(substr_count("", "a", 0, 0));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
int(0)
|
||||
Reference in New Issue
Block a user