#40710 [Opn->Csd]: str_ireplace crashes when working on array argument when no match found
| From: | iliaa@php.net | Date: | Sun, 04 Mar 2007 16:11:20 +0000 |
| Subject: | #40710 [Opn->Csd]: str_ireplace crashes when working on array argument when no match found | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-109865@lists.php.net to get a copy of this message | ||
ID: 40710
Updated by: iliaa@php.net
Reported By: zend at ryank dot net
-Status: Open
+Status: Closed
Bug Type: Strings related
Operating System: Windows XP SP2
PHP Version: 5.2.1
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2007-03-03 16:47:00] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40710&edit=1