Bug #13901 Updated: str_replace() seqfaults with empty string in array argument
| From: | andrei@php.net | Date: | Sun, 11 Nov 2001 00:01:42 +0000 |
| Subject: | Bug #13901 Updated: str_replace() seqfaults with empty string in array argument | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-70037@lists.php.net to get a copy of this message | ||
ID: 13901
Updated by: andrei
Reported By: steve_cayford@unioncab.com
Status: Assigned
Bug Type: Reproducible crash
Operating System: Linux PPC (2.2.18) and MacOSX 10
PHP Version: 4.0.6
Assigned To: andrei
New Comment:
Fixed in CVS - thanks.
Previous Comments:
------------------------------------------------------------------------
[2001-11-01 14:54:51] steve_cayford@unioncab.com
I'm using str_replace to fill out mailing label templates with data from a database. When I
came up with a record with empty string fields I got a seqfault. I've tracked the problem down
to str_replace -- simplified in the following script. If you insert a space in
$replaceArray['NAME'] or add a space at the end of $lines[0] after {name} it won't
segfault. Note that the ADDRESS field has the same layout, but doesn't cause a segfault,
however if I reduce the arrays to *just* the NAME fields, then it doesn't segfault either.
Weirdness.
<?php
$searchArray = array (
"NAME" => "{name}",
"ADDRESS" => "{address}" );
$replaceArray = array (
"NAME" => "",
"ADDRESS" => "" );
$lines = array(
"{name}",
"{address}",
"",
""
);
$newlines = str_replace($searchArray, $replaceArray, $lines);
print_r($lines);
print("<br>\n");
print_r($newlines);
print("<br>\n");
?>
On MacOSX I used this configuration:
--with-xml \
--with-zlib \
--with-apxs=/usr/sbin/apxs \
--with-openssl \
--enable-trans-sid \
--with-pdflib=/Users/steve/build/pdflib/pdflib-4.0.1/bind/c \ --enable-shared=pdflib \
--with-mysql=/usr/local
On Linux PPC (2.2.18) I used this configuration:
--with-xml \
--with-zlib \
--with-apxs=/usr/sbin/apxs \
--with-openssl \
--enable-trans-sid \
--with-pdflib=/usr/local \
--enable-shared=pdflib \
--with-mysql=/usr \
--enable-openbase_module
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=13901&edit=1