PHP 4.0 Bug #6472: str_replace with array causes system hang

From: Date: Thu, 31 Aug 2000 18:12:46 +0000
Subject: PHP 4.0 Bug #6472: str_replace with array causes system hang
Groups: php.dev 
Request: Send a blank email to php-dev+get-31478@lists.php.net to get a copy of this message
From: ppi@searchy.net 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

« previous php.dev (#31478) next »