]> granicus.if.org Git - php/commitdiff
Fixed exception constructor
authorDmitry Stogov <dmitry@zend.com>
Fri, 21 Feb 2014 12:14:42 +0000 (16:14 +0400)
committerDmitry Stogov <dmitry@zend.com>
Fri, 21 Feb 2014 12:14:42 +0000 (16:14 +0400)
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_exceptions.c
Zend/zend_object_handlers.c

index 80eb984b17e9250048d6b9e7b7201e48b6705dee..e2737a270caa1a0230d88ea0f0cf49dae744ec89 100644 (file)
@@ -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;
index 7f8f30d8f29b6c76f70a461b6ae9a9bd8556ff30..3aeac177f0bc916c8dd41e485f8114a120076e11 100644 (file)
@@ -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);
 
index 9473751ae431228f3806e90642d2f8bc71ab917a..48779b47ec7ac410043a7ee7384a09c1974be27e 100644 (file)
@@ -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) {
index bbda58cff9d6e9354b7fcc68d3e822223756e8c8..6acb504e5f193d64116c204e929864b287c83c52 100644 (file)
@@ -579,6 +579,7 @@ found:
                                                zval_ptr_dtor(&garbage);
                                        }
                                }
+                               return;
                        }
                }
        }