Initialize out parameters to NULL.
authorRolf Bjarne Kvinge <rolf@xamarin.com>
Thu, 8 May 2014 14:57:17 +0000 (16:57 +0200)
committerRolf Bjarne Kvinge <rolf@xamarin.com>
Thu, 8 May 2014 15:01:27 +0000 (17:01 +0200)
Fixes a crash in the debugger, where we were freeing random pointers:

(lldb)
frame #2: 0x000dc981 monotouchtest`method_commands_internal(command=<unavailable>, method=<unavailable>, domain=<unavailable>, p=0x7f52aca4, end=<unavailable>, buf=<unavailable>) + 9009 at debugger-agent.c:8116
   8113 g_free (il_offsets);
   8114 g_free (line_numbers);
   8115 g_free (column_numbers);
-> 8116 g_free (end_line_numbers);
   8117 g_free (end_column_numbers);
   8118 g_free (source_files);
   8119 g_ptr_array_free (source_file_list, TRUE);

mono/metadata/debug-mono-symfile.c

index 0962499eebe9b04af7cc8636f99d35fdef46416e..79f6cda6a54ce93fd152bd556aa1f99542327ca6 100644 (file)
@@ -524,12 +524,20 @@ mono_debug_symfile_get_line_numbers_full (MonoDebugMethodInfo *minfo, char **sou
                *source_file_list = NULL;
        if (n_il_offsets)
                *n_il_offsets = 0;
+       if (il_offsets)
+               *il_offsets = NULL;
        if (source_files)
                *source_files = NULL;
        if (source_file)
                *source_file = NULL;
+       if (line_numbers)
+               *line_numbers = NULL;
        if (column_numbers)
                *column_numbers = NULL;
+       if (end_line_numbers)
+               *end_line_numbers = NULL;
+       if (end_column_numbers)
+               *end_column_numbers = NULL;
 
        if ((symfile = minfo->handle->symfile) == NULL)
                return;