]> granicus.if.org Git - php/commitdiff
MF51: fix bug #36898 (__set() leaks in classes extending internal ones)
authorAntony Dovgal <tony2001@php.net>
Wed, 29 Mar 2006 15:08:52 +0000 (15:08 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 29 Mar 2006 15:08:52 +0000 (15:08 +0000)
Added:
ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC)
ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC)

17 files changed:
Zend/zend_objects.c
Zend/zend_objects.h
ext/com_dotnet/com_persist.c
ext/date/php_date.c
ext/dom/php_dom.c
ext/mysqli/mysqli.c
ext/reflection/php_reflection.c
ext/simplexml/simplexml.c
ext/spl/spl_array.c
ext/spl/spl_directory.c
ext/spl/spl_iterators.c
ext/spl/spl_observer.c
ext/sqlite/sqlite.c
ext/tidy/tidy.c
ext/xmlreader/php_xmlreader.c
ext/xmlwriter/php_xmlwriter.c
ext/xsl/php_xsl.c

index 416e9cace3ffb0d10aff67f8b0f24f3844b0c3cf..cf81e6c519c311fc1616dbe08f950274100a4522 100644 (file)
 #include "zend_API.h"
 #include "zend_interfaces.h"
 
+ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC)
+{
+       ALLOC_HASHTABLE(object->properties);
+       zend_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+
+       object->ce = ce;        
+       object->guards = NULL;
+}
+
+ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC)
+{
+       if (object->guards) {
+               zend_hash_destroy(object->guards);
+               FREE_HASHTABLE(object->guards);         
+       }
+       if (object->properties) {
+               zend_hash_destroy(object->properties);
+               FREE_HASHTABLE(object->properties);
+       }
+}
 
 ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC)
 {
index b1d50379f4f95c0e1ab79e5dfaeb4ac9a832f02b..ebeaf896782987e4776e12ba3b5e7a62dcb5e30b 100644 (file)
@@ -25,6 +25,8 @@
 #include "zend.h"
 
 BEGIN_EXTERN_C()
+ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC);
+ZEND_API void zend_object_std_dtor(zend_object *object TSRMLS_DC);
 ZEND_API zend_object_value zend_objects_new(zend_object **object, zend_class_entry *class_type TSRMLS_DC);
 ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handle handle TSRMLS_DC);
 ZEND_API zend_object *zend_objects_get_address(zval *object TSRMLS_DC);
index b8c438df51ee4a1cf59fd4c061c522055697743b..f9e327fbb252c66af1615e8170f376cd263bcf22 100755 (executable)
@@ -701,8 +701,7 @@ static void helper_free_storage(void *obj TSRMLS_DC)
        if (object->unk) {
                IUnknown_Release(object->unk);
        }
-       zend_hash_destroy(object->std.properties);
-       FREE_HASHTABLE(object->std.properties);
+       zend_object_std_dtor(&object->std TSRMLS_CC);
        efree(object);
 }
 
@@ -715,9 +714,8 @@ static void helper_clone(void *obj, void **clone_ptr TSRMLS_DC)
        memcpy(clone, object, sizeof(*object));
        *clone_ptr = clone;
 
-       ALLOC_HASHTABLE(clone->std.properties);
-       zend_hash_init(clone->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-       
+       zend_object_std_init(&clone->std, object->std.ce TSRMLS_CC);
+
        if (clone->ipf) {
                IPersistFile_AddRef(clone->ipf);
        }
@@ -740,9 +738,7 @@ static zend_object_value helper_new(zend_class_entry *ce TSRMLS_DC)
        helper = emalloc(sizeof(*helper));
        memset(helper, 0, sizeof(*helper));
 
-       ALLOC_HASHTABLE(helper->std.properties);
-       zend_hash_init(helper->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-       helper->std.ce = helper_ce;
+       zend_object_std_init(&helper->std, helper_ce TSRMLS_CC);
        
        retval.handle = zend_objects_store_put(helper, NULL, helper_free_storage, helper_clone TSRMLS_CC);
        retval.handlers = &helper_handlers;
index b1aeb7e96a4a352c56de42edd9cd906e6a4fa8a0..9895f941602ad422a8429b2de93e5405672c8220 100644 (file)
@@ -1359,10 +1359,8 @@ static zend_object_value date_object_new_date(zend_class_entry *class_type TSRML
 
        intern = emalloc(sizeof(php_date_obj));
        memset(intern, 0, sizeof(php_date_obj));
-       intern->std.ce = class_type;
        
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        
        retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_date, NULL TSRMLS_CC);
@@ -1379,10 +1377,8 @@ static zend_object_value date_object_new_timezone(zend_class_entry *class_type T
 
        intern = emalloc(sizeof(php_timezone_obj));
        memset(intern, 0, sizeof(php_timezone_obj));
-       intern->std.ce = class_type;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        
        retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) date_object_free_storage_timezone, NULL TSRMLS_CC);
@@ -1402,12 +1398,7 @@ static void date_object_free_storage_date(void *object TSRMLS_DC)
                timelib_time_dtor(intern->time);
        }
 
-       if (intern->std.properties) {
-               zend_hash_destroy(intern->std.properties);
-               efree(intern->std.properties);
-               intern->std.properties = NULL;
-       }
-       
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
        efree(object);
 }
 
@@ -1415,12 +1406,7 @@ static void date_object_free_storage_timezone(void *object TSRMLS_DC)
 {
        php_timezone_obj *intern = (php_timezone_obj *)object;
 
-       if (intern->std.properties) {
-               zend_hash_destroy(intern->std.properties);
-               efree(intern->std.properties);
-               intern->std.properties = NULL;
-       }
-
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
        efree(object);
 }
 
index 0273f80b1b67329113c5737db6000bea242a81ee..f06f7badb8d781c6ad06210fdec7453fa0d0192e 100644 (file)
@@ -934,8 +934,7 @@ void dom_xpath_objects_free_storage(void *object TSRMLS_DC)
 {
        dom_object *intern = (dom_object *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        if (intern->ptr != NULL) {
                xmlXPathFreeContext((xmlXPathContextPtr) intern->ptr);
@@ -954,8 +953,7 @@ void dom_objects_free_storage(void *object TSRMLS_DC)
        dom_object *intern = (dom_object *)object;
        int retcount;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        if (intern->ptr != NULL && ((php_libxml_node_ptr *)intern->ptr)->node != NULL) {
                if (((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_DOCUMENT_NODE && ((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != XML_HTML_DOCUMENT_NODE) {
@@ -1001,8 +999,6 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool
        dom_object *intern;
 
        intern = emalloc(sizeof(dom_object));
-       intern->std.ce = class_type;
-       intern->std.guards = NULL;
        intern->ptr = NULL;
        intern->prop_handler = NULL;
        intern->document = NULL;
@@ -1014,8 +1010,7 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool
 
        zend_u_hash_find(UG(unicode)?&u_classes:&classes, UG(unicode)?IS_UNICODE:IS_STRING, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler);
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        if (hash_copy) {
                zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        }
@@ -1120,8 +1115,7 @@ void dom_nnodemap_objects_free_storage(void *object TSRMLS_DC)
 
        php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC);
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        efree(object);
 }
index 8b1ca3bff670496ef3a542a6c8f77fbb9bc48b57..9e46b3876673661f1a4077ef8bbc45f7aca087a4 100644 (file)
@@ -123,8 +123,9 @@ void php_clear_mysql(MY_MYSQL *mysql) {
 static void mysqli_objects_free_storage(zend_object *object TSRMLS_DC)
 {
        mysqli_object   *intern = (mysqli_object *)object;
-       
-       zend_objects_free_object_storage(&(intern->zo) TSRMLS_CC);
+
+       zend_object_std_dtor(&intern->zo TSRMLS_CC);
+       efree(intern);
 }
 /* }}} */
 
@@ -345,8 +346,6 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
 
        intern = emalloc(sizeof(mysqli_object));
        memset(intern, 0, sizeof(mysqli_object));
-       intern->zo.ce = class_type;
-       intern->zo.guards = NULL;
        intern->ptr = NULL;
        intern->valid = 0;
        intern->prop_handler = NULL;
@@ -359,8 +358,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
        zend_hash_find(&classes, mysqli_base_class->name.s, mysqli_base_class->name_length + 1, 
                                        (void **) &intern->prop_handler);
 
-       ALLOC_HASHTABLE(intern->zo.properties);
-       zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,
                                        (void *) &tmp, sizeof(zval *));
 
index 259bebddcb8241012e68c04cf773544c6c0c2a86..5dac6120b737fde7e967cea0bac78a33b22bee65 100644 (file)
@@ -235,9 +235,7 @@ static void reflection_objects_clone(void *object, void **object_clone TSRMLS_DC
        reflection_object **intern_clone = (reflection_object **) object_clone;
 
        *intern_clone = emalloc(sizeof(reflection_object));
-       (*intern_clone)->zo.ce = intern->zo.ce;
-       (*intern_clone)->zo.guards = NULL;
-       ALLOC_HASHTABLE((*intern_clone)->zo.properties);
+       zend_object_std_init(&(*intern_clone)->zo, intern->zo.ce TSRMLS_CC);
        (*intern_clone)->ptr = intern->ptr;
        (*intern_clone)->free_ptr = intern->free_ptr;
        (*intern_clone)->obj = intern->obj;
@@ -253,14 +251,11 @@ static zend_object_value reflection_objects_new(zend_class_entry *class_type TSR
        reflection_object *intern;
 
        intern = emalloc(sizeof(reflection_object));
-       intern->zo.ce = class_type;
-       intern->zo.guards = NULL;
        intern->ptr = NULL;
        intern->obj = NULL;
        intern->free_ptr = 0;
 
-       ALLOC_HASHTABLE(intern->zo.properties);
-       zend_u_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0, UG(unicode));
+       zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
        zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, reflection_objects_clone TSRMLS_CC);
        retval.handlers = &reflection_object_handlers;
index 70182def08c9c317283c73ce7a224cdc53f64498..d6e75004eb47488c7c3eaac4430f44e21d5300ca 100644 (file)
@@ -1752,9 +1752,8 @@ static void sxe_object_free_storage(void *object TSRMLS_DC)
 
        sxe = (php_sxe_object *) object;
 
-       zend_hash_destroy(sxe->zo.properties);
-       FREE_HASHTABLE(sxe->zo.properties);
-
+       zend_object_std_dtor(&sxe->zo TSRMLS_CC);
+       
        php_libxml_node_decrement_resource((php_libxml_node_object *)sxe TSRMLS_CC);
 
        if (sxe->xpath) {
@@ -1777,14 +1776,12 @@ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce TSRMLS_DC)
        php_sxe_object *intern;
 
        intern = ecalloc(1, sizeof(php_sxe_object));
-       intern->zo.ce = ce;
 
        intern->iter.type = SXE_ITER_NONE;
        intern->iter.nsprefix = NULL;
        intern->iter.name = NULL;
 
-       ALLOC_HASHTABLE(intern->zo.properties);
-       zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->zo, ce TSRMLS_CC);
 
        return intern;
 }
index 6f0d38b742fdf6bf37ced32c146a692211d80ee6..4c28b66decdfb329d8d273216e3627c71d49715e 100755 (executable)
@@ -109,8 +109,7 @@ static void spl_array_object_free_storage(void *object TSRMLS_DC)
 {
        spl_array_object *intern = (spl_array_object *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        zval_ptr_dtor(&intern->array);
        zval_ptr_dtor(&intern->retval);
@@ -132,12 +131,10 @@ static zend_object_value spl_array_object_new_ex(zend_class_entry *class_type, s
 
        intern = emalloc(sizeof(spl_array_object));
        memset(intern, 0, sizeof(spl_array_object));
-       intern->std.ce = class_type;
        *obj = intern;
        ALLOC_INIT_ZVAL(intern->retval);
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        intern->ar_flags = 0;
index 3cd1e73538f813140b9ed170cfa04d1b74820fad..e8cfb54b711e929d57360c608b018d378e011564 100755 (executable)
@@ -73,9 +73,9 @@ static void spl_filesystem_object_free_storage(void *object TSRMLS_DC) /* {{{ */
        if (intern->oth_handler && intern->oth_handler->dtor) {
                intern->oth_handler->dtor(intern TSRMLS_CC);
        }
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
-
+       
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
+       
        if (intern->path) {
                efree(intern->path);
        }
@@ -132,14 +132,12 @@ static zend_object_value spl_filesystem_object_new_ex(zend_class_entry *class_ty
 
        intern = emalloc(sizeof(spl_filesystem_object));
        memset(intern, 0, sizeof(spl_filesystem_object));
-       intern->std.ce = class_type;
        /* intern->type = SPL_FS_INFO; done by set 0 */
        intern->file_class = spl_ce_SplFileObject;
        intern->info_class = spl_ce_SplFileInfo;
        if (obj) *obj = intern;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_filesystem_object_free_storage, NULL TSRMLS_CC);
index c6c4d0ce69b60055b900a4de1a3b811e7d7eb704..63d290c58900e95f98a18f4388dd4b6827519760 100755 (executable)
@@ -687,8 +687,7 @@ static void spl_RecursiveIteratorIterator_free_storage(void *_object TSRMLS_DC)
                object->iterators = NULL;
        }
 
-       zend_hash_destroy(object->std.properties);
-       FREE_HASHTABLE(object->std.properties);
+       zend_object_std_dtor(&object->std TSRMLS_CC);
 
        efree(object);
 }
@@ -703,10 +702,8 @@ static zend_object_value spl_RecursiveIteratorIterator_new(zend_class_entry *cla
 
        intern = emalloc(sizeof(spl_recursive_it_object));
        memset(intern, 0, sizeof(spl_recursive_it_object));
-       intern->std.ce = class_type;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_RecursiveIteratorIterator_free_storage, NULL TSRMLS_CC);
@@ -1385,8 +1382,7 @@ static inline void spl_dual_it_free_storage(void *_object TSRMLS_DC)
        }
 #endif
 
-       zend_hash_destroy(object->std.properties);
-       FREE_HASHTABLE(object->std.properties);
+       zend_object_std_dtor(&object->std TSRMLS_CC);
 
        efree(object);
 }
@@ -1401,11 +1397,9 @@ static zend_object_value spl_dual_it_new(zend_class_entry *class_type TSRMLS_DC)
 
        intern = emalloc(sizeof(spl_dual_it_object));
        memset(intern, 0, sizeof(spl_dual_it_object));
-       intern->std.ce = class_type;
        intern->dit_type = DIT_Unknown;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_dual_it_free_storage, NULL TSRMLS_CC);
index d20912c5e5d20b6a786f87c942a62a14b8f64ade..05bc75c978bbc24929406a3a0856b69e0c38b634 100755 (executable)
@@ -85,9 +85,8 @@ void spl_SplOjectStorage_free_storage(void *object TSRMLS_DC) /* {{{ */
 {
        spl_SplObjectStorage *intern = (spl_SplObjectStorage *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
-
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
+       
        zend_hash_destroy(&intern->storage);
 
        efree(object);
@@ -101,11 +100,9 @@ static zend_object_value spl_object_storage_new_ex(zend_class_entry *class_type,
 
        intern = emalloc(sizeof(spl_SplObjectStorage));
        memset(intern, 0, sizeof(spl_SplObjectStorage));
-       intern->std.ce = class_type;
        *obj = intern;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        zend_hash_init(&intern->storage, 0, NULL, ZVAL_PTR_DTOR, 0);
index b1df8487db079563dc6fdcf27f16e14c531767f8..720bc08fd1dde42db7abc762e329b97262100790 100644 (file)
@@ -796,8 +796,7 @@ static void sqlite_object_free_storage(void *object TSRMLS_DC)
 {
        sqlite_object *intern = (sqlite_object *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        if (intern->u.ptr) {
                if (intern->type == is_db) {
@@ -820,10 +819,8 @@ static void sqlite_object_new(zend_class_entry *class_type, zend_object_handlers
 
        intern = emalloc(sizeof(sqlite_object));
        memset(intern, 0, sizeof(sqlite_object));
-       intern->std.ce = class_type;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        retval->handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) sqlite_object_free_storage, NULL TSRMLS_CC);
index f72319cb3991d63b663982b38ef910b3fbadf639..5717dfb6f42dcfa1cf903dc970b90a6367c6c9bf 100644 (file)
@@ -530,8 +530,7 @@ static void tidy_object_free_storage(void *object TSRMLS_DC)
 {
        PHPTidyObj *intern = (PHPTidyObj *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        if (intern->ptdoc) {
                intern->ptdoc->ref_count--;
@@ -555,10 +554,8 @@ static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *
 
        intern = emalloc(sizeof(PHPTidyObj));
        memset(intern, 0, sizeof(PHPTidyObj));
-       intern->std.ce = class_type;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        switch(objtype) {
index 20de2c9d9fe59f29801073cf0528d688f2da8bf7..2edfcc8f4c21906d24f61d1774e897b52365e7e7 100644 (file)
@@ -378,8 +378,7 @@ void xmlreader_objects_free_storage(void *object TSRMLS_DC)
 {
        xmlreader_object *intern = (xmlreader_object *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
        
        xmlreader_free_resources(intern);
 
@@ -396,13 +395,11 @@ zend_object_value xmlreader_objects_new(zend_class_entry *class_type TSRMLS_DC)
 
        intern = emalloc(sizeof(xmlreader_object));
        memset(&intern->std, 0, sizeof(zend_object));
-       intern->std.ce = class_type;
        intern->ptr = NULL;
        intern->schema = NULL;
        intern->prop_handler = &xmlreader_prop_handlers;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) xmlreader_objects_free_storage, xmlreader_objects_clone TSRMLS_CC);
        intern->handle = retval.handle;
index 386c2034c7e85de0ddedf547e9418ac0e9ec226d..7404f35eba0d31840cc2faaa59bca2483c124188 100644 (file)
@@ -80,11 +80,8 @@ static void xmlwriter_object_free_storage(void *object TSRMLS_DC)
                xmlwriter_free_resource_ptr(intern->xmlwriter_ptr TSRMLS_CC);
        }
        intern->xmlwriter_ptr = NULL;
-       if (intern->zo.properties) {
-               zend_hash_destroy(intern->zo.properties);
-               FREE_HASHTABLE(intern->zo.properties);
-       }
-
+       zend_object_std_dtor(&intern->zo TSRMLS_CC);
+       
        efree(intern);
 }
 /* }}} */
@@ -99,11 +96,9 @@ PHP_XMLWRITER_API zend_object_value xmlwriter_object_new(zend_class_entry *class
 
        intern = emalloc(sizeof(ze_xmlwriter_object));
        memset(&intern->zo, 0, sizeof(zend_object));
-       intern->zo.ce = class_type;
        intern->xmlwriter_ptr = NULL;
        
-       ALLOC_HASHTABLE(intern->zo.properties);
-       zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
        zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref,
                                        (void *) &tmp, sizeof(zval *));
 
index c57f952a310594da1fae364270031100730210ee..c8b396aca057d97548f603d3f82511026b69c079 100644 (file)
@@ -80,8 +80,7 @@ void xsl_objects_free_storage(void *object TSRMLS_DC)
 {
        xsl_object *intern = (xsl_object *)object;
 
-       zend_hash_destroy(intern->std.properties);
-       FREE_HASHTABLE(intern->std.properties);
+       zend_object_std_dtor(&intern->std TSRMLS_CC);
 
        zend_hash_destroy(intern->parameter);
        FREE_HASHTABLE(intern->parameter);
@@ -119,8 +118,6 @@ zend_object_value xsl_objects_new(zend_class_entry *class_type TSRMLS_DC)
        zval *tmp;
 
        intern = emalloc(sizeof(xsl_object));
-       intern->std.ce = class_type;
-       intern->std.guards = NULL;
        intern->ptr = NULL;
        intern->prop_handler = NULL;
        intern->parameter = NULL;
@@ -130,8 +127,7 @@ zend_object_value xsl_objects_new(zend_class_entry *class_type TSRMLS_DC)
        intern->node_list = NULL;
        intern->doc = NULL;
 
-       ALLOC_HASHTABLE(intern->std.properties);
-       zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
        zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        ALLOC_HASHTABLE(intern->parameter);
        zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0);