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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nikic@php.net
New email:
PHP Version: OS:

 

 [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 15:01:30 2024 UTC