php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74041 substr_count with length=0 broken
Submitted: 2017-02-03 16:50 UTC Modified: -
From: nikic@php.net Assigned:
Status: Closed Package: *General Issues
PHP Version: 7.1.1 OS:
Private report: No CVE-ID: None
 [2017-02-03 16:50 UTC] nikic@php.net
Description:
------------
substr_count() with length=0 currently is interpreted as using length=strlen(haystack) instead. This bug has been introduced during the implementation of negative offset support.

https://3v4l.org/fdbpO

Test script:
---------------
<?php
var_dump(substr_count("aaa", "a", 0, 0));

Expected result:
----------------
int(0)

Actual result:
--------------
int(3)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-03 16:55 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8660e95b4c7a7a84278104bce4ad8270c1ac3464
Log: Fixed bug #74041
 [2017-02-03 16:55 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC