[PHP-DEV] PHP 4.0 Bug #6472: str_replace with array causes system hang From: ppi <email protected>
Date: 08/31/00

From: ppi <email protected>
Operating system: Linux 2.2.13
PHP version: 4.0.0
PHP Bug Type: Scripting Engine problem
Bug description: str_replace with array causes system hang

I have this function build in a page:

function sponsor1() {
        $time = time();
        echo "\n<center>\n";
        $bannerarray = file("bannercode.txt");
        $count = count($bannerarray);
        for ($i = 0; $i <= count($bannerarray); $i++) {
                $bannerarray[($i)] = str_replace ("%random%", $time, $bannerarray[($i)]);
                echo $bannerarray[($i)];
        }
        echo "\n</center>\n<br>";
}

This will cause in a tremedous memory overflow (the HTTP Deamon needs all memory he can find, so the systems hangs because it's too busy with the swap-partion.

But if I change something in the 'for' loop there's no problem:

$printthis = str_replace ("%random%", $time, $bannerarray[($i)]);
echo $printthis;

This sound me like a little bug in the function 'str_replace'. When this is not fixed in later versions of PHP (I couldn't find it in the changelogs, so it must be) this bug should be there...

I thought I had configured Php with one of these two :
./configure --with-mysql --with-gd=/usr/lib --with-jpeg-dir=/usr/lib --with-apache=../apache_1.3.12 --enable-track-vars

./configure --with-mysql --with-gd=../gd-1.8.2 --with-jpeg-dir=../jpeg-6b --with-apache=../apache_1.3.12 --enable-track-vars

and apache with this one:

./configure --activate-module=src/modules/php4/libphp4.a --with-layout=config.layout:SuSE --enable-module=so

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>