tony2001 Tue Jun 5 10:02:02 2007 UTC Added files: /php-src/ext/simplexml/tests bug41582.phpt
Modified files: /php-src/ext/simplexml simplexml.c Log: fix #41582 (SimpleXML crashes when accessing newly created element) http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.232&r2=1.233&diff_format=u Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.232 php-src/ext/simplexml/simplexml.c:1.233 --- php-src/ext/simplexml/simplexml.c:1.232 Mon May 28 23:14:57 2007 +++ php-src/ext/simplexml/simplexml.c Tue Jun 5 10:02:02 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.232 2007/05/28 23:14:57 iliaa Exp $ */ +/* $Id: simplexml.c,v 1.233 2007/06/05 10:02:02 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -238,7 +238,7 @@ /* {{{ sxe_prop_dim_read() */ -static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, zend_bool silent TSRMLS_DC) +static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, zend_bool attribs, int type TSRMLS_DC) { zval *return_value; php_sxe_object *sxe; @@ -249,6 +249,12 @@ int nodendx = 0; int test = 0; + if (!member) { + return_value = &EG(uninitialized_zval); + return_value->is_ref = 1; + return return_value; + } + sxe = php_sxe_fetch_object(object TSRMLS_CC); if (Z_TYPE_P(member) == IS_LONG) { @@ -357,7 +363,7 @@ */ static zval * sxe_property_read(zval *object, zval *member, int type TSRMLS_DC) { - return sxe_prop_dim_read(object, member, 1, 0, type == BP_VAR_IS TSRMLS_CC); + return sxe_prop_dim_read(object, member, 1, 0, type TSRMLS_CC); } /* }}} */ @@ -365,7 +371,7 @@ */ static zval * sxe_dimension_read(zval *object, zval *offset, int type TSRMLS_DC) { - return sxe_prop_dim_read(object, offset, 0, 1, 0 TSRMLS_CC); + return sxe_prop_dim_read(object, offset, 0, 1, type TSRMLS_CC); } /* }}} */ @@ -2425,7 +2431,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.232 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.233 $"); php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug41582.phpt?view=markup&rev=1.1 Index: php-src/ext/simplexml/tests/bug41582.phpt +++ php-src/ext/simplexml/tests/bug41582.phpt --TEST-- Bug #41582 (SimpleXML crashes when accessing newly created element) --FILE-- <?php $xml = new SimpleXMLElement(b'<?xml version="1.0" standalone="yes"?><collection></collection>'); $xml->movie[]->characters->character[0]->name = b'Miss Coder'; var_dump($xml->asXml()); echo "Done\n"; ?> --EXPECTF-- Fatal error: Cannot use object of type stdClass as array in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php