[aot] Avoid a crash in the aot compiler if a delegate doesn't have a BeginInvoke...
authorZoltan Varga <vargaz@gmail.com>
Fri, 6 Jan 2017 00:44:42 +0000 (19:44 -0500)
committerZoltan Varga <vargaz@gmail.com>
Fri, 6 Jan 2017 00:46:53 +0000 (19:46 -0500)
mono/mini/aot-compiler.c

index f5e1c67b47c7466d25aca75b862588bd9cce1950..3b4470fc3c6472580602dbb2037dc710b60dda6e 100644 (file)
@@ -4066,30 +4066,33 @@ add_wrappers (MonoAotCompile *acfg)
 
                        /* begin-invoke */
                        method = mono_get_delegate_begin_invoke (klass);
-                       create_gsharedvt_inst (acfg, method, &ctx);
+                       if (method) {
+                               create_gsharedvt_inst (acfg, method, &ctx);
 
-                       inst = mono_class_inflate_generic_method_checked (method, &ctx, &error);
-                       g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+                               inst = mono_class_inflate_generic_method_checked (method, &ctx, &error);
+                               g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
 
-                       m = mono_marshal_get_delegate_begin_invoke (inst);
-                       g_assert (m->is_inflated);
+                               m = mono_marshal_get_delegate_begin_invoke (inst);
+                               g_assert (m->is_inflated);
 
-                       gshared = mini_get_shared_method_full (m, FALSE, TRUE);
-                       add_extra_method (acfg, gshared);
+                               gshared = mini_get_shared_method_full (m, FALSE, TRUE);
+                               add_extra_method (acfg, gshared);
+                       }
 
                        /* end-invoke */
                        method = mono_get_delegate_end_invoke (klass);
-                       create_gsharedvt_inst (acfg, method, &ctx);
-
-                       inst = mono_class_inflate_generic_method_checked (method, &ctx, &error);
-                       g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+                       if (method) {
+                               create_gsharedvt_inst (acfg, method, &ctx);
 
-                       m = mono_marshal_get_delegate_end_invoke (inst);
-                       g_assert (m->is_inflated);
+                               inst = mono_class_inflate_generic_method_checked (method, &ctx, &error);
+                               g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
 
-                       gshared = mini_get_shared_method_full (m, FALSE, TRUE);
-                       add_extra_method (acfg, gshared);
+                               m = mono_marshal_get_delegate_end_invoke (inst);
+                               g_assert (m->is_inflated);
 
+                               gshared = mini_get_shared_method_full (m, FALSE, TRUE);
+                               add_extra_method (acfg, gshared);
+                       }
                }
        }