Skip to content

Commit

Permalink
fix<fix_leak>: fix some leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
majerugo committed Jan 22, 2024
1 parent 1d0507d commit bb514d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ast/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser_functionnal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bb514d9

Please sign in to comment.