From:             david at acz dot org
Operating system: SuSE Linux
PHP version:      5.2.3
PHP Bug Type:     SimpleXML related
Bug description:  Implicit conversion to string leaks memory

Description:
------------
Passing a SimpleXML string object to most builtin string functions causes
a memory leak.

Reproduce code:
---------------
#!/usr/local/bin/php -d memory_limit=128M
<?
    $xml = '<?xml version="1.0" encoding="utf-8"?>';
    $x = simplexml_load_string($xml . "<q><x>foo</x></q>");

    echo "explicit conversion\n";
    for ($i = 0; $i < 1000000; $i++)
        md5(strval($x->x));

    echo "no conversion\n";
    for ($i = 0; $i < 1000000; $i++)
        md5($x->x);

    echo "done\n";
?>


Expected result:
----------------
$ ./crash.php
explicit conversion
no conversion
done


Actual result:
--------------
$ ./crash.php
explicit conversion
no conversion

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to
allocate 40 bytes) in /tmp/crash.php on line 12


-- 
Edit bug report at http://bugs.php.net/?id=42369&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42369&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42369&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42369&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42369&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42369&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42369&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42369&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42369&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42369&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42369&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42369&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42369&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42369&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42369&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42369&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42369&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42369&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42369&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42369&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42369&r=mysqlcfg

Reply via email to