diff --git a/Zend/zend.c b/Zend/zend.c index a060602aba6..485c6a38803 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -417,7 +417,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int } ZEND_PUTS_EX(" Object\n"); if (class_name) { - efree((char*)class_name); + STR_RELEASE(class_name); } if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) { break; diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 80eb984b17e..e2737a270ca 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3694,6 +3694,15 @@ ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, } /* }}} */ +ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_string *value TSRMLS_DC) /* {{{ */ +{ + zval tmp; + + ZVAL_STR(&tmp, STR_COPY(value)); + zend_update_property(scope, object, name, name_length, &tmp TSRMLS_CC); +} +/* }}} */ + ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC) /* {{{ */ { zval tmp; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 7f8f30d8f29..3aeac177f0b 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -323,6 +323,7 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC); ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, long value TSRMLS_DC); ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC); +ZEND_API void zend_update_property_str(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_string *value TSRMLS_DC); ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC); ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, int value_length TSRMLS_DC); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 9473751ae43..48779b47ec7 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -160,6 +160,7 @@ static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type, object_properties_init(object, class_type); zend_fetch_debug_backtrace(&trace, skip_top_traces, 0, 0 TSRMLS_CC); + Z_SET_REFCOUNT(trace, 0); zend_update_property_string(default_exception_ce, &obj, "file", sizeof("file")-1, zend_get_executed_filename(TSRMLS_C) TSRMLS_CC); zend_update_property_long(default_exception_ce, &obj, "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC); @@ -194,19 +195,19 @@ ZEND_METHOD(exception, __clone) Exception constructor */ ZEND_METHOD(exception, __construct) { - char *message = NULL; + zend_string *message = NULL; long code = 0; zval *object, *previous = NULL; - int argc = ZEND_NUM_ARGS(), message_len; + int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|slO!", &message, &message_len, &code, &previous, default_exception_ce) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SlO!", &message, &code, &previous, default_exception_ce) == FAILURE) { zend_error(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])"); } object = getThis(); if (message) { - zend_update_property_stringl(default_exception_ce, object, "message", sizeof("message")-1, message, message_len TSRMLS_CC); + zend_update_property_str(default_exception_ce, object, "message", sizeof("message")-1, message TSRMLS_CC); } if (code) { diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index eef85d51e78..9029f45cc43 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -579,6 +579,7 @@ found: zval_ptr_dtor(&garbage); } } + return; } } } @@ -1604,7 +1605,7 @@ int zend_std_get_closure(zval *obj, zend_class_entry **ce_ptr, zend_function **f ZEND_API zend_object_handlers std_object_handlers = { zend_object_free, /* free_obj */ - zend_object_std_dtor, /* dtor_obj */ + zend_objects_destroy_object, /* dtor_obj */ zend_objects_clone_obj, /* clone_obj */ zend_std_read_property, /* read_property */ diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 8e406ec7154..6f80771ce6a 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -129,7 +129,7 @@ ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */ */ if (EG(objects_store).object_buckets && IS_VALID(EG(objects_store).object_buckets[object->handle])) { - if (object->gc.refcount == 1) { + if (object->gc.refcount == 0) { int failure = 0; if (!(object->gc.u.v.flags & IS_OBJ_DESTRUCTOR_CALLED)) { @@ -146,7 +146,7 @@ ZEND_API void zend_objects_store_del(zend_object *object TSRMLS_DC) /* {{{ */ } } - if (object->gc.refcount == 1) { + if (object->gc.refcount == 0) { zend_uint handle = object->handle; //??? GC_REMOVE_ZOBJ_FROM_BUFFER(obj);