Free the other two fields of script_desc which somehow got overlooked,
free malloc'ed args in case exec fails, and add missing checks for
failed mallocs.
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
static void script_desc__delete(struct script_desc *s)
{
free(s->name);
+ free(s->half_liner);
+ free(s->args);
free(s);
}
close(live_pipe[0]);
__argv = malloc(6 * sizeof(const char *));
+ if (!__argv)
+ die("malloc");
+
__argv[0] = "/bin/sh";
__argv[1] = record_script_path;
__argv[2] = "-q";
__argv[5] = NULL;
execvp("/bin/sh", (char **)__argv);
+ free(__argv);
exit(-1);
}
close(live_pipe[1]);
__argv = malloc((argc + 3) * sizeof(const char *));
+ if (!__argv)
+ die("malloc");
__argv[0] = "/bin/sh";
__argv[1] = report_script_path;
for (i = 2; i < argc; i++)
__argv[i++] = NULL;
execvp("/bin/sh", (char **)__argv);
+ free(__argv);
exit(-1);
}
}
__argv = malloc((argc + 1) * sizeof(const char *));
+ if (!__argv)
+ die("malloc");
__argv[0] = "/bin/sh";
__argv[1] = script_path;
for (i = 3; i < argc; i++)
__argv[argc - 1] = NULL;
execvp("/bin/sh", (char **)__argv);
+ free(__argv);
exit(-1);
}