- Standard:
. Fixed bug #74005 (mail.add_x_header causes RFC-breaking lone line feed).
(Anatol)
+ . Fixed bug #74041 (substr_count with length=0 broken). (Nikita)
16 Feb 2017, PHP 7.1.2
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;
}
--- /dev/null
+--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)