From 6a34fd2d2ee2159ebc8d1927de55bf9cc2a7dc8d Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 29 Nov 2023 16:52:35 +0000 Subject: Fixed incorrect free of tokens in error for preprocess_use_blocks Also error now points to the correct place in the file. --- asm/parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asm/parser.c b/asm/parser.c index c97028d..0830ef3 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -378,8 +378,8 @@ perr_t preprocess_use_blocks(token_stream_t *stream, token_stream_t *new) if (i + 1 >= stream->available || DARR_AT(token_t, stream->data, i + 1).type != TOKEN_LITERAL_STRING) { - stream->used = i; - for (size_t i = 0; i < new_stream.available; ++i) + stream->used = i + 1 >= stream->available ? i : i + 1; + for (size_t i = 0; i < (new_stream.available / sizeof(token_t)); ++i) free(TOKEN_STREAM_AT(new_stream.data, i).str); free(new_stream.data); return PERR_PREPROCESSOR_EXPECTED_STRING; -- cgit v1.2.3-13-gbd6f