perf script: Fix double free on command_line
authorColin Ian King <[email protected]>
Tue, 1 Mar 2016 23:46:20 +0000 (23:46 +0000)
committerArnaldo Carvalho de Melo <[email protected]>
Thu, 3 Mar 2016 14:10:37 +0000 (11:10 -0300)
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 <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: He Kuang <[email protected]>
Cc: Javi Merino <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/scripting-engines/trace-event-python.c

index 309d90fa7698c3e67a316baad19a7daf751a1c4f..fbd05242b4e59786ca0e081a52729248d780f5a0 100644 (file)
@@ -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) {
@@ -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();