[static registrar] Go straight to exception handling after invoking the managed method if an exception occurred. (#11714)

This fixes a memory corruption where we'd try to process out parameters when
an exception had occurred, and those out parameters weren't expected to be
processed.
This commit is contained in:
Rolf Bjarne Kvinge 2021-05-28 07:44:18 +02:00 коммит произвёл GitHub
Родитель b538801293
Коммит e11ad011d9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -3795,6 +3795,7 @@ namespace Registrar {
}
var marshal_exception = "NULL";
var post_invoke_check = string.Empty;
if (App.MarshalManagedExceptions != MarshalManagedExceptionMode.Disable) {
body_setup.AppendLine ("MonoObject *exception = NULL;");
if (App.EnableDebug && App.IsDefaultMarshalManagedExceptionMode) {
@ -3803,6 +3804,7 @@ namespace Registrar {
} else {
marshal_exception = "&exception";
}
post_invoke_check = "if (exception != NULL) goto exception_handling;";
}
if (!isVoid) {
@ -3813,6 +3815,9 @@ namespace Registrar {
invoke.AppendLine ("mono_runtime_invoke (managed_method, {0}, arg_ptrs, {1});", isStatic ? "NULL" : "mthis", marshal_exception);
if (!string.IsNullOrEmpty (post_invoke_check))
invoke.AppendLine (post_invoke_check);
body_setup.AppendLine ("GCHandle exception_gchandle = INVALID_GCHANDLE;");
// prepare the return value
if (!isVoid) {