From 4960d5f2cac1d3abd1de58d07e152d97aaabc663 Mon Sep 17 00:00:00 2001 From: adjoly Date: Thu, 1 Aug 2024 17:40:43 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20fixed?= =?UTF-8?q?=20error=20when=20infile=20alone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parsing/split_cmd.c | 4 +++- src/utils/free_list.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/parsing/split_cmd.c b/src/parsing/split_cmd.c index c1dba2d..5f3d61c 100644 --- a/src/parsing/split_cmd.c +++ b/src/parsing/split_cmd.c @@ -6,7 +6,7 @@ /* By: mmoussou argv = NULL; + cmd->cmd = NULL; split = split_argv(cmd_av); if (!split) { diff --git a/src/utils/free_list.c b/src/utils/free_list.c index af22b7b..de790cf 100644 --- a/src/utils/free_list.c +++ b/src/utils/free_list.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/04 20:10:35 by adjoly #+# #+# */ -/* Updated: 2024/07/10 01:19:32 by adjoly ### ########.fr */ +/* Updated: 2024/08/01 17:40:10 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,12 +37,14 @@ void free_cmd(void *content) t_cmd *cmd; cmd = (t_cmd *)content; - if (cmd->cmd) - free(cmd->cmd); + if (!cmd) + return ; if (cmd->infile != STDIN_FILENO && cmd->infile != -1) close(cmd->infile); if (cmd->outfile != STDOUT_FILENO && cmd->outfile != -1) close(cmd->outfile); + if (cmd->cmd) + free(cmd->cmd); if (cmd->argv) ft_free("a", &(cmd->argv)); if (cmd)