tony2001                Tue Jun  5 10:03:13 2007 UTC

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

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/simplexml      simplexml.c 
  Log:
  MFH: fix #41582 (SimpleXML crashes when accessing newly created element)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.758&r2=1.2027.2.547.2.759&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.758 php-src/NEWS:1.2027.2.547.2.759
--- php-src/NEWS:1.2027.2.547.2.758     Tue Jun  5 07:49:00 2007
+++ php-src/NEWS        Tue Jun  5 10:03:12 2007
@@ -10,6 +10,8 @@
   exists (pecl bug #11216) (Pierre)
   GD_RELEASE_VERSION, GD_EXTRA_VERSION and GD_VERSION_STRING. (Pierre)
 - Fixed bug #41594 (Statement cache is flushed too frequently). (Tony)
+- Fixed bug #41582 (SimpleXML crashes when accessing newly created element).
+  (Tony)
 - Fixed bug #41576 (configure failure when using --without-apxs or some
   other SAPIs disabling options). (Jani)
 - Fixed bug #41567 (json_encode() double conversion is inconsistent with
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.151.2.22.2.26&r2=1.151.2.22.2.27&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.26 
php-src/ext/simplexml/simplexml.c:1.151.2.22.2.27
--- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.26   Tue Apr 24 14:11:28 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Jun  5 10:03:12 2007
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.151.2.22.2.26 2007/04/24 14:11:28 iliaa Exp $ */
+/* $Id: simplexml.c,v 1.151.2.22.2.27 2007/06/05 10:03:12 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);
 }
 /* }}} */
 
@@ -2368,7 +2374,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.26 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.27 $");
        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

Reply via email to