diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-09 12:42:31 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-09 12:42:31 +0200 |
| commit | eeeeed44a9c7e8bd2f6a579bcace1f90d8a040ec (patch) | |
| tree | 69dff03e1188e168af2ce5b2b7ce6a792999eb4b /src/parser/parser.c | |
| parent | 6b200dc03c8233f6cd49111540002eb9b5aac4ec (diff) | |
| download | minishell-eeeeed44a9c7e8bd2f6a579bcace1f90d8a040ec.tar.gz minishell-eeeeed44a9c7e8bd2f6a579bcace1f90d8a040ec.tar.bz2 minishell-eeeeed44a9c7e8bd2f6a579bcace1f90d8a040ec.zip | |
Fixing parenthesis leak in parser, Fixing crash on empty input
Diffstat (limited to 'src/parser/parser.c')
| -rw-r--r-- | src/parser/parser.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/parser/parser.c b/src/parser/parser.c index e861232..9d5a99d 100644 --- a/src/parser/parser.c +++ b/src/parser/parser.c @@ -6,7 +6,7 @@ /* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/17 18:09:04 by nahaddac #+# #+# */ -/* Updated: 2020/10/09 11:10:55 by cacharle ### ########.fr */ +/* Updated: 2020/10/09 12:35:51 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -107,7 +107,6 @@ t_parsed *parse_pipeline(t_tok_lst *input) { ast_destroy(expr->ast); free(expr); - /* tok_lst_destroy(expr->rest, free); */ return (parsed_error("syntax error expected token")); } tail = parse_pipeline(expr->rest); @@ -211,7 +210,11 @@ t_parsed *parse_expr(t_tok_lst *input) return (parsed); input = parsed->rest; if (input == NULL || !(input->tag & TAG_PARENT_CLOSE)) + { + ast_destroy(parsed->ast); + free(parsed); return (parsed_error("syntax error expected token")); + } tok_lst_pop_front(&input, free); if ((ast = ast_new(AST_PARENT)) == NULL) return (NULL); |
