Skip to content

Commit

Permalink
Fix for dynamic library loading in mir-run
Browse files Browse the repository at this point in the history
Initialize temp_string array and use malloc instead of alloca
  • Loading branch information
Wiguwbe committed Jan 15, 2024
1 parent 80392c7 commit 7110b21
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mir-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void lib_dirs_from_env_var(const char *env_var) {

// copy to an allocated buffer
int value_len = strlen(var_value);
char *value = (char*)alloca(value_len+1);
char *value = (char*)malloc(value_len+1);
strcpy(value, var_value);

// colon separated list
Expand Down Expand Up @@ -270,7 +270,7 @@ void open_extra_libs(void) {
return;

int value_len = strlen(var_value);
char *value = (char*)alloca(value_len+1);
char *value = (char*)malloc(value_len+1);
strcpy(value, var_value);

char *value_ptr = value;
Expand Down Expand Up @@ -299,6 +299,7 @@ int main (int argc, char **argv, char **envp) {
MIR_val_t val;
int exit_code;

VARR_CREATE (char, temp_string, 0);
VARR_CREATE (lib_t, extra_libs, 16);
VARR_CREATE (char_ptr_t, lib_dirs, 16);
for(int i=0; i < sizeof(std_lib_dirs) / sizeof(char_ptr_t); i++)
Expand Down

0 comments on commit 7110b21

Please sign in to comment.