Re: [PATCH 3/3] sub-process: allocate argv on the heap
Am 03.10.2017 um 21:57 schrieb Thomas Gummerer:
Show 16 quoted lines
> diff --git a/sub-process.c b/sub-process.c
> index 6dde5062be..4680af8193 100644
> --- a/sub-process.c
> +++ b/sub-process.c
> @@ -77,7 +77,9 @@ int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, co
> {
> int err;
> struct child_process *process;
> - const char *argv[] = { cmd, NULL };
> + const char **argv = xmalloc(2 * sizeof(char *));
> + argv[0] = cmd;
> + argv[1] = NULL;
>
> entry->cmd = cmd;
> process = &entry->process;
> Perhaps this should become
argv_array_push(&process->args, cmd);
so that there is no new memory leak?
-- Hannes