|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46752 str_replace / str_ireplace memory leak
Submitted: 2008-12-04 23:29 UTC Modified: 2008-12-06 18:34 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: daniel dot konopka at gmail dot com Assigned:
Status: Closed Package: Strings related
PHP Version: 5.2.6 OS: Linux CentOS
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.
Block user comment
Status: Assign to:
Bug Type:
From: daniel dot konopka at gmail dot com
New email:
PHP Version: OS:


 [2008-12-04 23:29 UTC] daniel dot konopka at gmail dot com
str_replace and str_ireplace cause a memory leak

Reproduce code:
$chars_ph = array('-');
$chars_rep = array('045]');
$subject = 'Programmable 15-Bar Pump-Espresso Coffee Machine';
$i = 0;

do {
$subject = str_replace($chars_rep, $subject);
while ($i<100000);

Actual result:
Php script execution stops after exceeding php memory pool.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-06 15:57 UTC] crrodriguez at opensuse dot org
There is no memory leak and your code is wrong, anyway..
 [2008-12-06 18:33 UTC] daniel dot konopka at gmail dot com
Ahh, I see what you mean. I simply forgot the search argument since I was writing it in a slight hurry. I am very sorry for my mistake. I am going to close the report.
 [2008-12-06 18:34 UTC] daniel dot konopka at gmail dot com
It was a big mistake by me, I forgot to pass correct arguments to the function. The bug is not there.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Feb 29 13:01:32 2024 UTC