|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40710 str_ireplace crashes when working on array argument when no match found
Submitted: 2007-03-03 16:47 UTC Modified: 2007-03-04 16:11 UTC
From: zend at ryank dot net Assigned:
Status: Closed Package: Strings related
PHP Version: 5.2.1 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zend at ryank dot net
New email:
PHP Version: OS:


 [2007-03-03 16:47 UTC] zend at ryank dot net
Using str_ireplace on array elements passed to a function causes PHP crash or apache(2.2.4) crash if the needle is not found.

In the repo code, if you use the line:

$record = array('DocumentDate' => '2007-03-02');

It will function correctly.

Workaround: use str_replace

Reproduce code:
function test($rec)
    $preped = array();
    $preped['DocumentDate'] = str_ireplace('-','',$rec['DocumentDate']);

    print ' prep okay? ';
    return $preped;

$record = array('DocumentDate' => '20070302');

print ' alive ';

$record = test($record);


print ' alive ';

Expected result:
alive prep okay? Array ( [DocumentDate] => 20070302 ) alive 

Actual result:
php crash or apache crash referencing php5ts.dll


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-04 16:11 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Jan 21 08:01:23 2020 UTC