Bug #75781 [Opn->Csd]: substr_count incorrect result
| From: | laruence@php.net | Date: | Tue, 09 Jan 2018 08:23:55 +0000 |
| Subject: | Bug #75781 [Opn->Csd]: substr_count incorrect result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213435@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75781&edit=1
ID: 75781
Updated by: laruence@php.net
Reported by: gajowy at agzeta dot pl
Summary: substr_count incorrect result
-Status: Open
+Status: Closed
Type: Bug
Package: Strings related
Operating System: Windows 10 64bit
PHP Version: 7.1.13
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6da44fefb2065e28c6329f45b40c5611f86f4bf3
Log: Fixed bug #75781 (substr_count incorrect result)
Previous Comments:
------------------------------------------------------------------------
[2018-01-08 22:52:58] gajowy at agzeta dot pl
Description:
------------
For "big" string the substr_count function returns incorrect result.
Memory limit in PHP set to 30GB.
Seems it works incorrect for strings>4GB.
Test script:
---------------
<?php
$size=9*1024*1024*1024; // 9GB
$buf=str_repeat(chr(0),$size);
for( $i=0; $i<$size; $i++ )
if( $i%3==0 )
$buf{$i}=chr(255);
$cnt=substr_count($buf,chr(255));
var_dump($cnt);
?>
Expected result:
----------------
int(3221225472)
Actual result:
--------------
int(-1073741824)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75781&edit=1