Fix: leaking memory from strdup in lttng-crash
authorAntoine Busque <abusque@efficios.com>
Sun, 13 Sep 2015 04:54:04 +0000 (00:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 17 Sep 2015 00:54:24 +0000 (20:54 -0400)
Signed-off-by: Antoine Busque <abusque@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-crash/lttng-crash.c

index 94943fbb9a857f5e972f5bb0e632f03032651ade..043acafaec7d50ed5aef39249b661dadeedd0e3c 100644 (file)
@@ -183,8 +183,8 @@ struct lttng_crash_layout {
 
 /* Variables */
 static char *progname,
-       *opt_viewer_path = DEFAULT_VIEWER,
-       *opt_output_path;
+       *opt_viewer_path = NULL,
+       *opt_output_path = NULL;
 
 static char *input_path;
 
@@ -291,9 +291,11 @@ static int parse_args(int argc, char **argv)
                        }
                        break;
                case 'e':
+                       free(opt_viewer_path);
                        opt_viewer_path = strdup(optarg);
                        break;
                case 'x':
+                       free(opt_output_path);
                        opt_output_path = strdup(optarg);
                        break;
                case OPT_DUMP_OPTIONS:
@@ -306,6 +308,10 @@ static int parse_args(int argc, char **argv)
                }
        }
 
+       if (!opt_viewer_path) {
+               opt_viewer_path = DEFAULT_VIEWER;
+       }
+
        /* No leftovers, or more than one input path, print usage and quit */
        if ((argc - optind) == 0 || (argc - optind) > 1) {
                usage(stderr);
This page took 0.025368 seconds and 4 git commands to generate.