From:             [EMAIL PROTECTED]
Operating system: Linux PPC (2.2.18) and MacOSX 10.1
PHP version:      4.0.6
PHP Bug Type:     Reproducible crash
Bug description:  str_replace() seqfaults with empty string in array argument

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 bug report at: http://bugs.php.net/?id=13901&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to