Skip to content

Commit

Permalink
perf script: Fix double free on command_line
Browse files Browse the repository at this point in the history
The 'command_line' variable is free'd twice if db_export__branch_types()
fails. To avoid this, defer the free'ing of 'command_line' to after this
call so that the error return path will just free 'command_line' once.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1456875980-25606-1-git-send-email-colin.king@canonical.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Colin Ian King authored and Arnaldo Carvalho de Melo committed Mar 3, 2016
1 parent 6767879 commit 979ac25
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/perf/util/scripting-engines/trace-event-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,6 @@ static int python_start_script(const char *script, int argc, const char **argv)
goto error;
}

free(command_line);

set_table_handlers(tables);

if (tables->db_export_mode) {
Expand All @@ -1104,6 +1102,8 @@ static int python_start_script(const char *script, int argc, const char **argv)
goto error;
}

free(command_line);

return err;
error:
Py_Finalize();
Expand Down

0 comments on commit 979ac25

Please sign in to comment.