}
}
+ MonoError isinst_error;
+ mono_error_init (&isinst_error);
if (ei->flags == MONO_EXCEPTION_CLAUSE_NONE && mono_object_isinst_checked (ex_obj, catch_class, &error)) {
setup_stack_trace (mono_ex, dynamic_methods, initial_trace_ips, &trace_ips);
g_slist_free (dynamic_methods);
MONO_CONTEXT_SET_IP (ctx, ei->handler_start);
return TRUE;
}
- mono_error_cleanup (&error);
+ mono_error_cleanup (&isinst_error);
}
}
mono_error_assert_ok (&error);
}
if (msg == NULL) {
- msg = message ? mono_string_to_utf8 ((MonoString *) message) : g_strdup ("(System.Exception.Message property not available)");
+ if (message) {
+ msg = mono_string_to_utf8_checked ((MonoString *) message, &error);
+ if (!is_ok (&error)) {
+ mono_error_cleanup (&error);
+ msg = g_strdup ("(error while display System.Exception.Message property)");
+ }
+ } else {
+ msg = g_strdup ("(System.Exception.Message property not available)");
+ }
}
g_print ("[%p:] EXCEPTION handling: %s.%s: %s\n", (void*)mono_native_thread_id_get (), mono_object_class (obj)->name_space, mono_object_class (obj)->name, msg);
g_free (msg);
MonoString *str = mono_object_to_string (exc, &other);
char *msg = NULL;
- if (str)
- msg = mono_string_to_utf8 (str);
+ if (str) {
+ MonoError inner_error;
+ msg = mono_string_to_utf8_checked (str, &inner_error);
+ if (!is_ok (&inner_error)) {
+ msg = g_strdup_printf ("Nested exception while formatting original exception");
+ mono_error_cleanup (&inner_error);
+ }
+ }
else if (other) {
char *original_backtrace = mono_exception_get_managed_backtrace ((MonoException*)exc);
char *nested_backtrace = mono_exception_get_managed_backtrace ((MonoException*)other);