[interp] Fix more MonoError reuse. (mono/mono#16262)
authorJay Krell <jaykrell@microsoft.com>
Thu, 15 Aug 2019 22:06:50 +0000 (15:06 -0700)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 15 Aug 2019 22:06:50 +0000 (00:06 +0200)
Commit migrated from https://github.com/mono/mono/commit/b654aa1ca858666539a677e96d00f594fd81c630

src/mono/mono/mini/interp/interp.c

index fde7888..3b46c5d 100644 (file)
@@ -2966,6 +2966,15 @@ mono_interp_load_remote_field_vt (
        return vt_sp + ALIGN_TO (i32, MINT_VT_ALIGNMENT);
 }
 
+static MONO_NEVER_INLINE gboolean
+mono_interp_isinst (MonoObject* object, MonoClass* klass)
+{
+       ERROR_DECL (error);
+       const gboolean isinst = mono_object_isinst_checked (object, klass, error) != NULL;
+       mono_error_cleanup (error); // FIXME: do not swallow the error
+       return isinst;
+}
+
 /*
  * GC SAFETY:
  *
@@ -4777,8 +4786,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                                        isinst = TRUE;
                                } else if (m_class_is_array_special_interface (c) || mono_object_is_transparent_proxy (o)) {
                                        /* slow path */
-                                       isinst = mono_object_isinst_checked (o, c, error) != NULL;
-                                       mono_error_cleanup (error); /* FIXME: don't swallow the error */
+                                       isinst = mono_interp_isinst (o, c); // FIXME: do not swallow the error
                                } else {
                                        isinst = FALSE;
                                }
@@ -4815,9 +4823,7 @@ interp_exec_method_full (InterpFrame *frame, ThreadContext *context, FrameClause
                        gboolean isinst_instr = *ip == MINT_ISINST;
                        c = (MonoClass*)imethod->data_items [*(guint16 *)(ip + 1)];
                        if ((o = sp [-1].data.o)) {
-                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, error);
-                               mono_error_cleanup (error); /* FIXME: don't swallow the error */
-                               if (!isinst_obj) {
+                               if (!mono_interp_isinst (o, c)) { // FIXME: do not swallow the error
                                        if (isinst_instr)
                                                sp [-1].data.p = NULL;
                                        else