fix: lexer_context is now freed on errors

This commit is contained in:
matteo 2026-01-31 10:59:45 +01:00
parent 64e3fb26c3
commit d95b0fd220
3 changed files with 16 additions and 16 deletions

View file

@ -257,16 +257,15 @@ struct token *new_token(char *begin, ssize_t size, struct token_info *info)
return tok;
}
void destroy_lexer_context(struct lexer_context **ctx)
void destroy_lexer_context(struct lexer_context *ctx)
{
if (ctx == NULL || *ctx == NULL)
if (ctx == NULL)
return;
if ((*ctx)->previous_token != NULL)
free((*ctx)->previous_token);
if ((*ctx)->current_token != NULL)
free((*ctx)->current_token);
free(*ctx);
*ctx = NULL;
if (ctx->previous_token != NULL)
free(ctx->previous_token);
if (ctx->current_token != NULL)
free(ctx->current_token);
free(ctx);
}
void free_token(struct token **tok)