Fix usage of mono_debug_get_seq_points to avoid leaks (mono/mono#15977)
authorJb Evain <jb@evain.net>
Sat, 3 Aug 2019 15:59:25 +0000 (08:59 -0700)
committerZoltan Varga <vargaz@gmail.com>
Sat, 3 Aug 2019 15:59:25 +0000 (11:59 -0400)
Commit migrated from https://github.com/mono/mono/commit/283c0557d376a7c680cfe5993d1ea872391bbf99

src/mono/mono/metadata/profiler.c
src/mono/mono/mini/debugger-agent.c
src/mono/mono/mini/mini-llvm.c

index bde18c0..190eaa0 100644 (file)
@@ -335,7 +335,6 @@ mono_profiler_get_coverage_data (MonoProfilerHandle handle, MonoMethod *method,
        MonoDebugMethodInfo *minfo = mono_debug_lookup_method (method);
 
        if (!info) {
-               char *source_file;
                int i, n_il_offsets;
                int *source_files;
                GPtrArray *source_file_list;
@@ -346,7 +345,7 @@ mono_profiler_get_coverage_data (MonoProfilerHandle handle, MonoMethod *method,
 
                /* Return 0 counts for all locations */
 
-               mono_debug_get_seq_points (minfo, &source_file, &source_file_list, &source_files, &sym_seq_points, &n_il_offsets);
+               mono_debug_get_seq_points (minfo, NULL, &source_file_list, &source_files, &sym_seq_points, &n_il_offsets);
                for (i = 0; i < n_il_offsets; ++i) {
                        MonoSymSeqPoint *sp = &sym_seq_points [i];
                        const char *srcfile = "";
index 018d92b..2eff36d 100644 (file)
@@ -3617,7 +3617,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo
                                        gpointer iter = NULL;
                                        MonoMethod *method;
                                        MonoDebugSourceInfo *sinfo;
-                                       char *source_file, *s;
+                                       char *s;
                                        gboolean found = FALSE;
                                        int i;
                                        GPtrArray *source_file_list;
@@ -3626,7 +3626,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo
                                                MonoDebugMethodInfo *minfo = mono_debug_lookup_method (method);
 
                                                if (minfo) {
-                                                       mono_debug_get_seq_points (minfo, &source_file, &source_file_list, NULL, NULL, NULL);
+                                                       mono_debug_get_seq_points (minfo, NULL, &source_file_list, NULL, NULL, NULL);
                                                        for (i = 0; i < source_file_list->len; ++i) {
                                                                sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i);
                                                                /*
index 49f2afc..ffed191 100644 (file)
@@ -9554,6 +9554,7 @@ emit_dbg_subprogram (EmitContext *ctx, MonoCompile *cfg, LLVMValueRef method, co
                source_file = g_strdup ("<unknown>");
        dir = g_path_get_dirname (source_file);
        filename = g_path_get_basename (source_file);
+       g_free (source_file);
 
        return (LLVMValueRef)mono_llvm_di_create_function (module->di_builder, module->cu, method, cfg->method->name, name, dir, filename, n_seq_points ? sym_seq_points [0].line : 1);
 }