aboutsummaryrefslogtreecommitdiff
path: root/src/program.c
diff options
context:
space:
mode:
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;