rrichards Thu Jan 31 21:58:57 2008 UTC Added files: (Branch: PHP_5_3) /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.35.2.9&r2=1.151.2.22.2.35.2.10&diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35.2.9 php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35.2.10 --- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.35.2.9 Tue Jan 29 09:59:42 2008 +++ php-src/ext/simplexml/simplexml.c Thu Jan 31 21:58:57 2008 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.151.2.22.2.35.2.9 2008/01/29 09:59:42 dmitry Exp $ */ +/* $Id: simplexml.c,v 1.151.2.22.2.35.2.10 2008/01/31 21:58:57 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1787,6 +1787,11 @@ } } + if (readobj == writeobj) { + INIT_PZVAL(writeobj); + zval_dtor(readobj); + } + rv = cast_object(writeobj, type, (char *)contents TSRMLS_CC); if (contents) { @@ -2507,7 +2512,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.35.2.9 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.35.2.10 $"); 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