Ensure exception out argument is initialized to NULL. (#5424)
authorJonathan Chambers <joncham@gmail.com>
Fri, 25 Aug 2017 07:38:11 +0000 (03:38 -0400)
committerZoltan Varga <vargaz@gmail.com>
Fri, 25 Aug 2017 07:38:11 +0000 (03:38 -0400)
mono/mini/debugger-agent.c
mono/mini/mini-runtime.c

index 016423072bd74048996f6c85363e28b6c52d90d7..e2df12bb6e649fee475908f0c64a3e95a6e3a226 100644 (file)
@@ -6982,7 +6982,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
        MonoMethodSignature *sig;
        guint8 **arg_buf;
        void **args;
-       MonoObject *this_arg, *res, *exc;
+       MonoObject *this_arg, *res, *exc = NULL;
        MonoDomain *domain;
        guint8 *this_buf;
 #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
@@ -7154,7 +7154,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8
 
        mono_stopwatch_start (&watch);
        res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer) this_buf : (gpointer) this_arg, args, &exc, &error);
-       if (exc == NULL && !mono_error_ok (&error)) {
+       if (!mono_error_ok (&error) && exc == NULL) {
                exc = (MonoObject*) mono_error_convert_to_exception (&error);
        } else {
                mono_error_cleanup (&error); /* FIXME report error */
index 3b74b398e1bfed72b0773d0216b02bfb7208313a..a3f4883f74d5fc7ffc43c20047a7f5d254dcbc37 100644 (file)
@@ -2622,6 +2622,8 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
 #endif
 
        error_init (error);
+       if (exc)
+               *exc = NULL;
 
        if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) {
                g_warning ("Ignoring invocation of an instance method on a NULL instance.\n");