From 9ef07f87a185115676a6805f25562570d937ad93 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 1 Aug 2024 09:48:48 +0200 Subject: [PATCH] Fix not freeing filename --- src/execution.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/execution.c b/src/execution.c index 18effc9..ce5ea53 100644 --- a/src/execution.c +++ b/src/execution.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/21 08:57:54 by ljiriste #+# #+# */ -/* Updated: 2024/08/01 09:28:18 by ljiriste ### ########.fr */ +/* Updated: 2024/08/01 09:47:44 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -135,7 +135,10 @@ int add_redirection_file(t_vec *redirections, t_parse_tree_node *io_file, int fd fd = STDIN_FILENO; sec_fd = open(filename, O_RDONLY); if (sec_fd < 0) + { + free(filename); return (1); + } redir = (t_redirection){.from_to_fds[0] = sec_fd, .from_to_fds[1] = fd, .created = 0}; } else @@ -147,9 +150,13 @@ int add_redirection_file(t_vec *redirections, t_parse_tree_node *io_file, int fd else sec_fd = open(filename, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); if (sec_fd == -1) + { + free(filename); return (1); + } redir = (t_redirection){.from_to_fds[0] = fd, .from_to_fds[1] = sec_fd, .created = 1}; } + free(filename); return (ft_vec_append(redirections, &redir) != success); } -- 2.30.2