aboutsummaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-29 16:52:35 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-29 16:58:26 +0000
commit6a34fd2d2ee2159ebc8d1927de55bf9cc2a7dc8d (patch)
tree584e4fb3d77359df4b674da600d5e5af512557d2 /asm
parentfd1e6d96f6c651c67d12677485445ade40f17645 (diff)
downloadovm-6a34fd2d2ee2159ebc8d1927de55bf9cc2a7dc8d.tar.gz
ovm-6a34fd2d2ee2159ebc8d1927de55bf9cc2a7dc8d.tar.bz2
ovm-6a34fd2d2ee2159ebc8d1927de55bf9cc2a7dc8d.zip
Fixed incorrect free of tokens in error for preprocess_use_blocks
Also error now points to the correct place in the file.
Diffstat (limited to 'asm')
-rw-r--r--asm/parser.c4
1 files 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;