diff --git a/src/ast/ast.c b/src/ast/ast.c index b5503415..a07bbfcb 100644 --- a/src/ast/ast.c +++ b/src/ast/ast.c @@ -59,8 +59,11 @@ void ast_free(struct ast_node *node) } if (node->type == AST_WORD || node->type == AST_WORD_ASSIGNMENT || node->type == AST_VARIABLE || node->type == AST_WORD_DOUBLE_QUOTE - || node->type == AST_IONUMBER) + || node->type == AST_IONUMBER || node->type == AST_REDIRECTION) + { free(node->value); + } + free(node); } diff --git a/src/parser/parser_functionnal.c b/src/parser/parser_functionnal.c index 65c0be17..e77113b6 100644 --- a/src/parser/parser_functionnal.c +++ b/src/parser/parser_functionnal.c @@ -23,13 +23,13 @@ struct ast_node *prefix(struct lexer *lexer) struct ast_node *redirection(struct lexer *lexer) { struct ast_node *current = ast_node_new(AST_REDIRECTION); + current->value = NULL; if (parser_peek(lexer) == TOKEN_IONUMBER) { struct ast_node *io_number = ast_node_new(AST_IONUMBER); io_number->value = lexer_pop(lexer).data; ast_append(current, io_number); } - if (parser_peek(lexer) == TOKEN_REDIR) { current->value = lexer_peek(lexer).data;