cvs: php-src /ext/simplexml simplexml.c
| From: | Rob Richards | Date: | Fri, 13 Feb 2004 15:05:19 +0000 |
| Subject: | cvs: php-src /ext/simplexml simplexml.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-26184@lists.php.net to get a copy of this message | ||
rrichards Fri Feb 13 10:05:19 2004 EDT
Modified files:
/php-src/ext/simplexml simplexml.c
Log:
Fix bug #27237: Working with simplexml crashes apache2
object dtor must be used to cleanup iterator data correctly
Fix asXML() outputing incorrect node
http://cvs.php.net/diff.php/php-src/ext/simplexml/simplexml.c?r1=1.130&r2=1.131&ty=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.130 php-src/ext/simplexml/simplexml.c:1.131
--- php-src/ext/simplexml/simplexml.c:1.130 Thu Feb 12 18:39:46 2004
+++ php-src/ext/simplexml/simplexml.c Fri Feb 13 10:05:18 2004
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: simplexml.c,v 1.130 2004/02/12 23:39:46 derick Exp $ */
+/* $Id: simplexml.c,v 1.131 2004/02/13 15:05:18 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -852,6 +852,7 @@
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
GET_NODE(sxe, node);
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
if (node) {
if (XML_DOCUMENT_NODE == node->parent->type) {
@@ -874,6 +875,7 @@
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
GET_NODE(sxe, node);
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
if (node) {
if (XML_DOCUMENT_NODE == node->parent->type) {
@@ -1088,27 +1090,41 @@
}
/* }}} */
-/* {{{ sxe_object_free_storage()
+/* {{{ sxe_object_dtor()
*/
-static void sxe_object_free_storage(void *object TSRMLS_DC)
+static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC)
{
+ /* dtor required to cleanup iterator related data properly */
+
php_sxe_object *sxe;
sxe = (php_sxe_object *) object;
- zend_hash_destroy(sxe->zo.properties);
- FREE_HASHTABLE(sxe->zo.properties);
-
if (sxe->iter.data) {
zval_ptr_dtor(&sxe->iter.data);
+ sxe->iter.data = NULL;
}
if (sxe->iter.name) {
xmlFree(sxe->iter.name);
+ sxe->iter.name = NULL;
}
if (sxe->iter.nsprefix) {
xmlFree(sxe->iter.nsprefix);
+ sxe->iter.nsprefix = NULL;
}
+}
+
+/* {{{ sxe_object_free_storage()
+ */
+static void sxe_object_free_storage(void *object TSRMLS_DC)
+{
+ php_sxe_object *sxe;
+
+ sxe = (php_sxe_object *) object;
+
+ zend_hash_destroy(sxe->zo.properties);
+ FREE_HASHTABLE(sxe->zo.properties);
php_libxml_node_decrement_resource((php_libxml_node_object *)sxe TSRMLS_CC);
@@ -1152,7 +1168,7 @@
{
zend_object_value rv;
- rv.handle = zend_objects_store_put(intern, NULL,
(zend_objects_free_object_storage_t)sxe_object_free_storage, sxe_object_clone TSRMLS_CC);
+ rv.handle = zend_objects_store_put(intern, sxe_object_dtor,
(zend_objects_free_object_storage_t)sxe_object_free_storage, sxe_object_clone TSRMLS_CC);
rv.handlers = (zend_object_handlers *) &sxe_object_handlers;
return rv;
@@ -1364,7 +1380,10 @@
{
php_sxe_iterator *iterator = (php_sxe_iterator *)iter;
- zval_ptr_dtor((zval**)&iterator->intern.data);
+ /* cleanup handled in sxe_object_dtor as we dont always have an iterator wrapper */
+ if (iterator->intern.data) {
+ zval_ptr_dtor((zval**)&iterator->intern.data);
+ }
efree(iterator);
}
@@ -1602,7 +1621,7 @@
{
php_info_print_table_start();
php_info_print_table_header(2, "Simplexml support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.130 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.131 $");
php_info_print_table_row(2, "Schema support",
#ifdef LIBXML_SCHEMAS_ENABLED
"enabled");