Fix memory leak in mono_aot_plt_resolve when exiting with exception
authorAndi McClure <andi.mcclure@xamarin.com>
Tue, 16 Feb 2016 21:45:53 +0000 (16:45 -0500)
committerAndi McClure <andi.mcclure@xamarin.com>
Tue, 16 Feb 2016 21:45:53 +0000 (16:45 -0500)
mono/mini/aot-runtime.c

index b082a6e3b0f2f7b0ed66b398e7e2d495020f6cbf..da6382a7ff893300fb7ee040fe80c64a9e35c099 100644 (file)
@@ -4638,13 +4638,17 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code
        if (mono_aot_only && ji.type == MONO_PATCH_INFO_METHOD && !ji.data.method->is_generic && !mono_method_check_context_used (ji.data.method) && !(ji.data.method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) &&
                !mono_method_needs_static_rgctx_invoke (ji.data.method, FALSE) && !using_gsharedvt) {
                target = (guint8 *)mono_jit_compile_method (ji.data.method, error);
-               if (!mono_error_ok (error))
+               if (!mono_error_ok (error)) {
+                       mono_mempool_destroy (mp);
                        return NULL;
+               }
                no_ftnptr = TRUE;
        } else {
                target = (guint8 *)mono_resolve_patch_target_checked (NULL, mono_domain_get (), NULL, &ji, TRUE, error);
-               if (!mono_error_ok (error))
+               if (!mono_error_ok (error)) {
+                       mono_mempool_destroy (mp);
                        return NULL;
+               }
        }
 
        /*