diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-09-16 20:25:08 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-09-16 20:25:08 +0200 |
| commit | 46c7f91cdceef0d5dd801ac569fb5d0c76b711aa (patch) | |
| tree | 3280c238a009d38896d3caa6c92601817d54ef87 /src/lexer/lexer.c | |
| parent | 3bb997212b3a0d140a34932f9deff52793673d49 (diff) | |
| download | minishell-46c7f91cdceef0d5dd801ac569fb5d0c76b711aa.tar.gz minishell-46c7f91cdceef0d5dd801ac569fb5d0c76b711aa.tar.bz2 minishell-46c7f91cdceef0d5dd801ac569fb5d0c76b711aa.zip | |
Fixing memory leaks in preprocess and parser
Diffstat (limited to 'src/lexer/lexer.c')
| -rw-r--r-- | src/lexer/lexer.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 26355fe..7a39373 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -6,7 +6,7 @@ /* By: nahaddac <nahaddac@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/07/16 08:18:25 by nahaddac #+# #+# */ -/* Updated: 2020/09/16 16:37:49 by charles ### ########.fr */ +/* Updated: 2020/09/16 20:17:10 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -105,12 +105,22 @@ t_tok_lst *create_token_list(char *input, t_tok_lst **lst) int lexer(char *input, t_tok_lst **out) { int status; + t_tok_lst *curr; if (!input) return (2); *out = NULL; *out = create_token_list(input, out); status = lexer_trim(*out); - return status; - + curr = *out; + while (curr != NULL) + { + if (!(curr->tag & TAG_IS_STR)) + { + free(curr->content); + curr->content = NULL; + } + curr = curr->next; + } + return (status); } |
