From 071f858996e1e9a5e5d34d7f561f3c26a332fb63 Mon Sep 17 00:00:00 2001 From: maple Date: Tue, 8 Aug 2023 10:58:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20leak=20with=20array[0]=20?= =?UTF-8?q?not=20malloc'd=20and=20free=20command=5Fargs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/exec/functions/execve.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/exec/functions/execve.c b/src/exec/functions/execve.c index 65536fe..6836077 100644 --- a/src/exec/functions/execve.c +++ b/src/exec/functions/execve.c @@ -35,7 +35,7 @@ char **get_cmd_args(t_token *input, char *command_path, size_t i) input = input->next; array[0] = ft_strdup(command_path); if (!array[0]) - return ((void)printf("Error Malloc in get_cmd_args\n"), NULL); + return (printf("Error Malloc in get_cmd_args\n"), free(array), NULL); while (input && i < size) { if (ft_strcmp(input->type, ARG) == 0) @@ -139,6 +139,7 @@ int execve_cmd(t_data *data, t_token *input, int block) if (command_args) execve(command_path, command_args, env_array); } + free_array(command_args); handle_execve_failure(data, block, command_path, env_array); rl_clear_history(); exit (status);