From bb514d97ce8ec6ed095cd35566a845bbd4a95a28 Mon Sep 17 00:00:00 2001 From: Ugo Majer Date: Mon, 22 Jan 2024 01:10:09 +0100 Subject: [PATCH] fix: fix some leaks --- src/ast/ast.c | 5 ++++- src/parser/parser_functionnal.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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;