[mono] Ensure exception_message points to a string (#72002)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thu, 11 Aug 2022 17:52:06 +0000 (10:52 -0700)
committerGitHub <noreply@github.com>
Thu, 11 Aug 2022 17:52:06 +0000 (10:52 -0700)
Co-authored-by: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
src/mono/mono/eventpipe/ep-rt-mono.c

index fba1368..f222b09 100644 (file)
@@ -3292,10 +3292,14 @@ ep_rt_mono_write_event_exception_thrown (MonoObject *obj)
                        flags |= EXCEPTION_THROWN_FLAGS_IS_CLS_COMPLIANT;
                        if (exception->inner_ex)
                                flags |= EXCEPTION_THROWN_FLAGS_HAS_INNER;
-                       exception_message = ep_rt_utf16_to_utf8_string (mono_string_chars_internal (exception->message), mono_string_length_internal (exception->message));
+                       if (exception->message)
+                               exception_message = ep_rt_utf16_to_utf8_string (mono_string_chars_internal (exception->message), mono_string_length_internal (exception->message));
                        hresult = exception->hresult;
                }
 
+               if (exception_message == NULL)
+                       exception_message = g_strdup ("");
+
                if (mono_get_eh_callbacks ()->mono_walk_stack_with_ctx)
                        mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (get_exception_ip_func, NULL, MONO_UNWIND_SIGNAL_SAFE, (void *)&ip);