From: Dmitry Stogov Date: Fri, 21 Feb 2014 12:14:42 +0000 (+0400) Subject: Fixed exception constructor X-Git-Tag: POST_PHPNG_MERGE~412^2~608 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6fbea9ce6a6382d7999b6f6059c16348ee50ecda;p=php Fixed exception constructor --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 80eb984b17..e2737a270c 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 7f8f30d8f2..3aeac177f0 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 9473751ae4..48779b47ec 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 bbda58cff9..6acb504e5f 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -579,6 +579,7 @@ found: zval_ptr_dtor(&garbage); } } + return; } } }