rrichards               Thu Jan 31 21:59:42 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/simplexml/tests        bug42369.phpt 

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  MFH: 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.151.2.22.2.37&r2=1.151.2.22.2.38&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.37 
php-src/ext/simplexml/simplexml.c:1.151.2.22.2.38
--- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.37   Mon Dec 31 07:20:11 2007
+++ php-src/ext/simplexml/simplexml.c   Thu Jan 31 21:59:41 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.151.2.22.2.37 2007/12/31 07:20:11 sebastian Exp $ */
+/* $Id: simplexml.c,v 1.151.2.22.2.38 2008/01/31 21:59:41 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1740,6 +1740,11 @@
                }
        }
 
+       if (readobj == writeobj) {
+               INIT_PZVAL(writeobj);
+               zval_dtor(readobj);
+       }
+
        rv = cast_object(writeobj, type, (char *)contents TSRMLS_CC);
 
        if (contents) {
@@ -2447,7 +2452,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.37 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.38 $");
        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