diff options
| author | Dominik Kaiser | 2025-01-25 15:58:12 +0100 |
|---|---|---|
| committer | GitHub | 2025-01-25 15:58:12 +0100 |
| commit | 3b97eaa0500314866c4a106c77e8f671c9751b89 (patch) | |
| tree | f44fffea0ef290f9bdf79448c90d794ba97b8ca4 /src/parser.c | |
| parent | bd8c817797d5f2b1affe6957ffc51846a38e70ec (diff) | |
| parent | 8fb5e2839cb7eb7bb72f577577afafcdbdc8a714 (diff) | |
| download | minishell-3b97eaa0500314866c4a106c77e8f671c9751b89.tar.gz minishell-3b97eaa0500314866c4a106c77e8f671c9751b89.zip | |
Merge memory leak fixes
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/parser.c b/src/parser.c index 13ab10d..8393cda 100644 --- a/src/parser.c +++ b/src/parser.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/29 15:53:29 by dkaiser #+# #+# */ -/* Updated: 2025/01/20 19:13:31 by chuhlig ### ########.fr */ +/* Updated: 2025/01/25 11:38:47 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,17 +19,24 @@ static t_token *find_token_by_type(t_token *tokens, int type); t_token *split_at_first(t_token **tokens, int type); static t_node *parse_statement(t_token *tokens, t_env **env); -t_list *parse(t_token *tokens, t_env **env) +t_node *parse(t_token *tokens, t_env **env) { t_node *result; - if ((*tokens).type == PIPE_TOKEN) + if ((*tokens).type == PIPE_TOKEN + || ((*tokens).type == REDIR_TOKEN && !(*tokens).next)) + { result = NULL; + free_tokens(tokens); + } else result = parse_statement(tokens, env); if (result == NULL) + { printf("Parsing error.\n"); - return (ft_lstnew(result)); + free_tokens(tokens); + } + return (result); } static t_node *parse_statement(t_token *tokens, t_env **env) @@ -70,7 +77,7 @@ t_token *split_at_first(t_token **tokens, int type) *tokens = split->next; if (result == split) result = NULL; - free_token(split); + free_token2(split); split = NULL; return (result); } |
