php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28048 using str_replace() together with while chaches PHP
Submitted: 2004-04-18 16:12 UTC Modified: 2004-04-18 16:45 UTC
From: johan at braattha dot se Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.3.4 OS: windows2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: johan at braattha dot se
New email:
PHP Version: OS:

 

 [2004-04-18 16:12 UTC] johan at braattha dot se
Description:
------------
When using str_replace() in a way it might not be thought (inside a while-loop where the statement is the actual str_replace one...) for (but still a valid one) it crashes php. This is 4 lines of code...


It just takes a while (less than a minute for me) before php actually crashes. I have not seen any updates on this bug in 4.3.5 or 4.3.6...

Reproduce code:
---------------
$string="I     hate    double      spaces.";
while ($string=str_replace("  "," ",$string)) {
$string=str_replace("  "," ",$string);
}

Expected result:
----------------
I expected $string to be: "I hate double spaces." I did not realise that str_replace() did this without the while loop... So everything works like a charm for me, but it might be problematic for other people?

Actual result:
--------------
A chrash... it takes a while and then apache restarts...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-18 16:45 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Try 4.3.6 first.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Feb 24 03:01:25 2020 UTC