rrichards               Thu Jan 31 21:58:09 2008 UTC

  Added files:                 
    /php-src/ext/simplexml/tests        bug42369.phpt 

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  fix bug #42369 (Implicit conversion to string leaks memory)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.251&r2=1.252&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.251 
php-src/ext/simplexml/simplexml.c:1.252
--- php-src/ext/simplexml/simplexml.c:1.251     Tue Jan 29 09:59:53 2008
+++ php-src/ext/simplexml/simplexml.c   Thu Jan 31 21:58:09 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.251 2008/01/29 09:59:53 dmitry Exp $ */
+/* $Id: simplexml.c,v 1.252 2008/01/31 21:58:09 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1844,6 +1844,11 @@
                }
        }
 
+       if (readobj == writeobj) {
+               INIT_PZVAL(writeobj);
+               zval_dtor(readobj);
+       }
+
        rv = cast_object(writeobj, type, (char *)contents, extra TSRMLS_CC);
 
        if (contents) {
@@ -2544,7 +2549,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.251 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.252 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug42369.phpt?view=markup&rev=1.1
Index: php-src/ext/simplexml/tests/bug42369.phpt
+++ php-src/ext/simplexml/tests/bug42369.phpt
--TEST--
Bug #42369 (Implicit conversion to string leaks memory)
--SKIPIF--
<?php if (!extension_loaded('simplexml')) echo 'skip simplexml extension is not 
loaded'; >
--FILE--
<?php
    $xml = '<?xml version="1.0" encoding="utf-8"?>';
    $x = simplexml_load_string($xml . "<q><x>foo</x></q>");

    echo 'explicit conversion' . PHP_EOL;
    for ($i = 0; $i < 100000; $i++) {
        md5(strval($x->x));
    }

    echo 'no conversion' . PHP_EOL;
    for ($i = 0; $i < 100000; $i++) {
        md5($x->x);
    }

    echo 'done' . PHP_EOL;
?>
--EXPECT--
explicit conversion
no conversion
done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to