ID:               37125
 Updated by:       [EMAIL PROTECTED]
 Reported By:      realbora at gmx dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         Strings related
 Operating System: windows 2000
 PHP Version:      5.1.2
 New Comment:

The error message are pretty clear:
Warning: preg_replace(): Compilation failed: unmatched parentheses at
offset 8 in .. on line 9
\\:\\-\\)
Warning: preg_replace(): Compilation failed: unmatched parentheses at
offset 6 in .. on line 9
;\\-\\)
\\:\\-\\}
Warning: preg_replace(): Compilation failed: unmatched parentheses at
offset 11 in .. on line 9
\\}\\:\\-\\)
\\:\\-\\#
\\:\\|
Fatal error: Allowed memory size of 8388608 bytes exhausted at
/usr/src/dev/clean/php-src_5_1/ext/pcre/php_pcre.c:955 (tried to
allocate 8519140 bytes)

No PHP bug -> bogus.


Previous Comments:
------------------------------------------------------------------------

[2006-04-18 20:34:58] realbora at gmx dot de

I think I made a mistake.
I found out, that I only have to modify the line
"$smilie[$i]=str_replace($regExp[$j],"\\"."\\".$regExp[$j],$smilie[$i])"
like that
"$smilie[$i]=str_replace($regExp[$j],"\\".$regExp[$j],$smilie[$i])".
And than it works.
But I think it's a little bit funny that the first code works 1 of 10
times.
OK.
Sorry that I interrupted you at your work. I know it's not easy for you
to solve so many problems without any deeper informations.

------------------------------------------------------------------------

[2006-04-18 19:50:29] [EMAIL PROTECTED]

We're not going to write a script for you here. You'll have to show us
that there is a bug, which you can do by providing us with a standalone
script that we don't have to modify.

------------------------------------------------------------------------

[2006-04-18 19:37:32] realbora at gmx dot de

I don`t have a Webserver with W2K on the web. I only got this problem
on my home-pc with a lokal webserver (IIS 5) for testing.
You don't need a database or any other resources for this script. You
only have do modify it a bit!

modified script without a need of resources:

$smilie=array(":-)",";-)",":-}","}:-)",":-#",":|");
$regExp=array(":","-","{","}","(",")","~","[","]","#","|");
$sql2=mysql_query('select * from smilies;');
for($i=0;$i<=count($smilie);$i++){
        for($j=0;$j<=count($regExp);$j++){
                
$smilie[$i]=str_replace($regExp[$j],"\\"."\\".$regExp[$j],$smilie[$i])
;
                }
        $file[$i]='<img border="0">';
        $neu_post=preg_replace("/$smilie[$i]/",$file[$i],$neu_post);
        echo $smilie[$i].'<br>';
        $neu_post1=substr($neu_post, 0, 60+$x);
}

------------------------------------------------------------------------

[2006-04-18 18:09:47] [EMAIL PROTECTED]

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.



------------------------------------------------------------------------

[2006-04-18 18:04:41] realbora at gmx dot de

Description:
------------
"str_replace" causes buffer overflow when using regexp's as replace!
When using regexp`s as the replacement in "str_replace" a system hangup
can cause.
Not ever, but in general is this the failure.

Reproduce code:
---------------
$regExp=array(":","-","{","}","(",")","~","[","]","#","|");
$sql2=mysql_query('select * from smilies;');
for($i=0;$temp2=mysql_fetch_array($sql2);$i++){
        $smilie[$i]=$temp2['smilie'];
        for($j=0;$j<=count($regExp);$j++){
                
$smilie[$i]=str_replace($regExp[$j],"\\"."\\".$regExp[$j],$smilie[$i]);
                }
        $file[$i]='<img border="0"
src="./bilder/smilies/'.$temp2['file'].'">';
        $neu_post=preg_replace("/$smilie[$i]/",$file[$i],$neu_post);
        echo $smilie[$i].'<br>';
        $neu_post1=substr($neu_post, 0, 60+$x);
}

Expected result:
----------------
Memoryuse grows very fast until system hangup.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37125&edit=1

Reply via email to