php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13901 str_replace() seqfaults with empty string in array argument
Submitted: 2001-11-01 14:54 UTC Modified: 2001-11-10 19:02 UTC
From: steve_cayford at unioncab dot com Assigned: andrei (profile)
Status: Closed Package: Reproducible crash
PHP Version: 4.0.6 OS: Linux PPC (2.2.18) and MacOSX 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: steve_cayford at unioncab dot com
New email:
PHP Version: OS:

 

 [2001-11-01 14:54 UTC] steve_cayford at unioncab dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-10 19:01 UTC] andrei@php.net
Fixed in CVS - thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 15:01:31 2025 UTC