- Removed the E_STRICT deprecation notice from "var". (Ilia)
- Fixed debug_zval_dump() to support private and protected members. (Dmitry)
- Fixed SoapFault::getMessage(). (Dmitry)
+- Fixed bug #36898 (__set() leaks in classes extending internal ones).
+ (Tony, Dmitry)
- Fixed bug #36886 (User filters can leak buckets in some situations). (Ilia)
- Fixed bug #36878 (error messages are printed even though an exception has
been thrown). (Tony)
#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)
{
ZEND_API void zend_objects_free_object_storage(zend_object *object TSRMLS_DC)
{
- if (object->guards) {
- zend_hash_destroy(object->guards);
- FREE_HASHTABLE(object->guards);
- }
- zend_hash_destroy(object->properties);
- FREE_HASHTABLE(object->properties);
+ zend_object_std_dtor(object TSRMLS_CC);
efree(object);
}
#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);
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);
}
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);
}
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;
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);
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);
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);
}
{
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);
}
{
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);
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) {
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;
zend_hash_find(&classes, 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 *));
}
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);
}
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);
}
/* }}} */
intern = emalloc(sizeof(mysqli_object));
memset(intern, 0, sizeof(mysqli_object));
- intern->zo.ce = class_type;
- intern->zo.guards = NULL;
intern->ptr = NULL;
intern->prop_handler = NULL;
zend_hash_find(&classes, mysqli_base_class->name, 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 *));
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;
intern->obj = NULL;
intern->free_ptr = 0;
- 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 *));
retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, reflection_objects_clone TSRMLS_CC);
retval.handlers = &reflection_object_handlers;
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) {
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;
}
{
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);
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;
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);
}
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);
object->iterators = NULL;
}
- zend_hash_destroy(object->std.properties);
- FREE_HASHTABLE(object->std.properties);
+ zend_object_std_dtor(&object->std TSRMLS_CC);
efree(object);
}
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);
zval_ptr_dtor(&object->u.append.zarrayit);
}
- zend_hash_destroy(object->std.properties);
- FREE_HASHTABLE(object->std.properties);
+ zend_object_std_dtor(&object->std TSRMLS_CC);
efree(object);
}
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);
{
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);
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);
{
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) {
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);
{
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--;
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) {
{
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);
zval *tmp;
intern = emalloc(sizeof(xmlreader_object));
- intern->std.ce = class_type;
- intern->std.guards = NULL;
intern->ptr = NULL;
intern->input = 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;
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);
}
/* }}} */
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 *));
{
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);
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;
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);