aboutsummaryrefslogtreecommitdiff
path: root/src/program.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-22 00:59:49 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commitd6f368a3f400fea3e89280262a8147e7ce5d855c (patch)
tree4eb64eb0d18dad1e40c70a5bff974fe8033fe389 /src/program.c
parentdf640dc7f55fef962b598562e10d8dd4d60fedc0 (diff)
Move thread work from compiler/parser to thread_work file, fix use after free bug in multithreaded parser allocator
Diffstat (limited to 'src/program.c')
-rw-r--r--src/program.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/program.c b/src/program.c
index 17aee03..082f9fd 100644
--- a/src/program.c
+++ b/src/program.c
@@ -216,6 +216,8 @@ static CHECK_RESULT int amal_program_read_strings(amal_program *self) {
if(bytes_left_to_read(self) < strings_size)
return AMAL_PROGRAM_INVALID_STRINGS_SIZE;
+ am_free(self->string_indices);
+ self->string_indices = NULL;
if(am_malloc(sizeof(u32) * self->num_strings, (void**)&self->string_indices) != 0)
return AMAL_PROGRAM_ALLOC_FAILURE;
string_index_ptr = self->string_indices;
@@ -266,6 +268,8 @@ static CHECK_RESULT int amal_program_read_external_functions(amal_program *self)
if(bytes_left_to_read(self) < extern_funcs_size)
return AMAL_PROGRAM_INVALID_EXTERNAL_FUNCTIONS_SIZE;
+ am_free(self->extern_func_indices);
+ self->extern_func_indices = NULL;
if(am_malloc(sizeof(u32) * self->num_extern_functions, (void**)&self->extern_func_indices) != 0)
return AMAL_PROGRAM_ALLOC_FAILURE;
extern_func_index_ptr = self->extern_func_indices;