From ec9177a513d1fdd510abcb70a9640d1bd94023f5 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 15 Jun 2020 11:01:03 +0200 Subject: Fixing leaks (need refactoring) --- src/preprocess.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/preprocess.c') diff --git a/src/preprocess.c b/src/preprocess.c index 278e8ef..1c59e28 100644 --- a/src/preprocess.c +++ b/src/preprocess.c @@ -6,13 +6,14 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/03 08:58:49 by charles #+# #+# */ -/* Updated: 2020/06/14 21:25:05 by charles ### ########.fr */ +/* Updated: 2020/06/15 10:47:24 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" #include "ms_glob.h" #include "lexer.h" +#include "eval.h" static bool st_escapable(char c, enum e_token_tag tag) { @@ -114,14 +115,18 @@ static void st_iter_func_unwrap_token(void **addr) } // need to free argv on error -char **preprocess(t_ftlst *tokens, t_env env) +char **preprocess(t_ftlst **tokens, t_env env) { size_t i; t_token *token; t_ftvec *argv; - if ((argv = ft_vecfrom_lst(tokens)) == NULL) + if ((argv = ft_vecfrom_lst(*tokens)) == NULL) + { + ft_lstdestroy(tokens, NULL); return (NULL); + } + ft_lstdestroy(tokens, NULL); i = -1; while (++i < argv->size) { @@ -160,7 +165,7 @@ char **preprocess(t_ftlst *tokens, t_env env) } // need to free tokens -char *preprocess_filename(t_ftlst *tokens, t_env env) +char *preprocess_filename(t_ftlst **tokens, t_env env) { char **strs; char *ret; @@ -170,7 +175,9 @@ char *preprocess_filename(t_ftlst *tokens, t_env env) return (NULL); if (strs[1] != NULL) { - // ambiguous + // save tokens + error_eval_put(ERROR_AMBIGUOUS_REDIR, strs[1]); + ft_split_destroy(strs); return (NULL); } ret = strs[0]; -- cgit