php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zend at ryank dot net
New email:
PHP Version: OS:

 

 [2007-03-03 16:47 UTC] zend at ryank dot net
Description:
------------
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_r($record);

print ' alive ';

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

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-04 16:11 UTC] iliaa@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC