Index: mini/mini.c =================================================================== --- mini/mini.c (revision 81651) +++ mini/mini.c (working copy) @@ -3747,6 +3747,7 @@ /* don't hide previous results */ cfg->exception_type = MONO_EXCEPTION_SECURITY_LINKDEMAND; cfg->exception_data = result; + return TRUE; } return FALSE; @@ -4505,8 +4506,12 @@ goto load_error; if (mono_use_security_manager) { - if (check_linkdemand (cfg, method, cmethod, bblock, ip)) - INLINE_FAILURE; + if (check_linkdemand (cfg, method, cmethod, bblock, ip)) { + if (cfg->exception_type != MONO_EXCEPTION_NONE) + goto security_error; + else + INLINE_FAILURE; + } } ins->inst_p0 = cmethod; @@ -4579,8 +4584,12 @@ n = fsig->param_count + fsig->hasthis; if (mono_use_security_manager) { - if (check_linkdemand (cfg, method, cmethod, bblock, ip)) - INLINE_FAILURE; + if (check_linkdemand (cfg, method, cmethod, bblock, ip)) { + if (cfg->exception_type != MONO_EXCEPTION_NONE) + goto security_error; + else + INLINE_FAILURE; + } } if (cmethod->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL && @@ -5566,8 +5575,12 @@ goto load_error; if (mono_use_security_manager) { - if (check_linkdemand (cfg, method, cmethod, bblock, ip)) - INLINE_FAILURE; + if (check_linkdemand (cfg, method, cmethod, bblock, ip)) { + if (cfg->exception_type != MONO_EXCEPTION_NONE) + goto security_error; + else + INLINE_FAILURE; + } } n = fsig->param_count; @@ -7228,8 +7241,12 @@ mono_class_init (cmethod->klass); if (mono_use_security_manager) { - if (check_linkdemand (cfg, method, cmethod, bblock, ip)) - INLINE_FAILURE; + if (check_linkdemand (cfg, method, cmethod, bblock, ip)) { + if (cfg->exception_type != MONO_EXCEPTION_NONE) + goto security_error; + else + INLINE_FAILURE; + } } handle_loaded_temps (cfg, bblock, stack_start, sp); @@ -7259,8 +7276,12 @@ mono_class_init (cmethod->klass); if (mono_use_security_manager) { - if (check_linkdemand (cfg, method, cmethod, bblock, ip)) - INLINE_FAILURE; + if (check_linkdemand (cfg, method, cmethod, bblock, ip)) { + if (cfg->exception_type != MONO_EXCEPTION_NONE) + goto security_error; + else + INLINE_FAILURE; + } } handle_loaded_temps (cfg, bblock, stack_start, sp); @@ -7688,6 +7709,12 @@ return inline_costs; + security_error: + g_assert (cfg->exception_type != MONO_EXCEPTION_NONE); + g_slist_free (class_inits); + dont_inline = g_list_remove (dont_inline, method); + return -1; + inline_failure: g_slist_free (class_inits); dont_inline = g_list_remove (dont_inline, method);