From: Jb Evain Date: Sat, 3 Aug 2019 15:59:25 +0000 (-0700) Subject: Fix usage of mono_debug_get_seq_points to avoid leaks (mono/mono#15977) X-Git-Tag: submit/tizen/20210909.063632~10331^2~5^2~864 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2806064fb0dc58f7fded76d9631b4df4e52eac7;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fix usage of mono_debug_get_seq_points to avoid leaks (mono/mono#15977) Commit migrated from https://github.com/mono/mono/commit/283c0557d376a7c680cfe5993d1ea872391bbf99 --- diff --git a/src/mono/mono/metadata/profiler.c b/src/mono/mono/metadata/profiler.c index bde18c0..190eaa0 100644 --- a/src/mono/mono/metadata/profiler.c +++ b/src/mono/mono/metadata/profiler.c @@ -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 = ""; diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index 018d92b..2eff36d 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -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); /* diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 49f2afc..ffed191 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -9554,6 +9554,7 @@ emit_dbg_subprogram (EmitContext *ctx, MonoCompile *cfg, LLVMValueRef method, co source_file = g_strdup (""); 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); }