tony2001                Tue Feb 20 13:22:41 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/simplexml      simplexml.c 
    /php-src    NEWS 
  Log:
  MFH: fix #38406 (crash when assigning objects to SimpleXML attributes)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.151.2.22.2.21&r2=1.151.2.22.2.22&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.21 
php-src/ext/simplexml/simplexml.c:1.151.2.22.2.22
--- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.21   Mon Feb 12 21:06:29 2007
+++ php-src/ext/simplexml/simplexml.c   Tue Feb 20 13:22:41 2007
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.151.2.22.2.21 2007/02/12 21:06:29 tony2001 Exp $ */
+/* $Id: simplexml.c,v 1.151.2.22.2.22 2007/02/20 13:22:41 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -56,6 +56,7 @@
 static zend_object_value php_sxe_register_object(php_sxe_object * TSRMLS_DC);
 static xmlNodePtr php_sxe_reset_iterator(php_sxe_object *sxe, int use_data 
TSRMLS_DC);
 static xmlNodePtr php_sxe_iterator_fetch(php_sxe_object *sxe, xmlNodePtr node, 
int use_data TSRMLS_DC);
+static zval *sxe_get_value(zval *z TSRMLS_DC);
 
 /* {{{ _node_as_zval()
  */
@@ -427,6 +428,7 @@
        int             is_attr = 0;
        int                             nodendx = 0;
        int             test = 0;
+       int                             new_value = 0;
        long            cnt;
        zval            tmp_zv, trim_zv, value_copy;
 
@@ -504,8 +506,17 @@
                                break;
                        case IS_STRING:
                                break;
+                       case IS_OBJECT:
+                               if (Z_OBJCE_P(value) == sxe_class_entry) {
+                                       value = sxe_get_value(value TSRMLS_CC);
+                                       INIT_PZVAL(value);
+                                       new_value = 1;
+                                       break;
+                               }
+                               /* break is missing intentionally */
                        default:
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "It 
is not yet possible to assign complex types to %s", attribs ? "attributes" : 
"properties");
+                               return;
                }
        }
 
@@ -594,6 +605,9 @@
        if (value && value == &value_copy) {
                zval_dtor(value);
        }
+       if (new_value) {
+               zval_ptr_dtor(&value);
+       }
 }
 /* }}} */
 
@@ -2342,7 +2356,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.21 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.22 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.552&r2=1.2027.2.547.2.553&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.552 php-src/NEWS:1.2027.2.547.2.553
--- php-src/NEWS:1.2027.2.547.2.552     Tue Feb 20 13:09:54 2007
+++ php-src/NEWS        Tue Feb 20 13:22:41 2007
@@ -39,6 +39,7 @@
 - Fixed bug #40109 (iptcembed fails on non-jfif jpegs). (Tony)
 - Fixed bug #39836 (SplObjectStorage empty after unserialize). (Marcus)
 - Fixed bug #39322 (proc_terminate() destroys process resource). (Nuno)
+- Fixed bug #38406 (crash when assigning objects to SimpleXML attributes). 
(Tony)
 - Fixed bug #37799 (ftp_ssl_connect() falls back to non-ssl connection). (Nuno)
 - Fixed bug #36496 (SSL support in imap_open() not working on Windows). (Edin)
 - Fixed bug #34794 (proc_close() hangs when used with two processes).

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

Reply via email to