diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 14:28:15 -0500 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 14:28:15 -0500 |
| commit | 7559df965ba3d96c792949790ad10b6f6350761c (patch) | |
| tree | 70df09b2d035f616c9ab875bfc8d06f11c168b24 /src | |
| parent | 10702c160a74a7becf0cdcd3e5c11419ff091d8b (diff) | |
| download | box64-7559df965ba3d96c792949790ad10b6f6350761c.tar.gz box64-7559df965ba3d96c792949790ad10b6f6350761c.zip | |
Fix memory issue when launching box86 from box64 main
Diffstat (limited to 'src')
| -rwxr-xr-x | src/main.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c index 10a505c7..0188fd1e 100755 --- a/src/main.c +++ b/src/main.c @@ -820,7 +820,7 @@ int main(int argc, const char **argv, const char **env) { // check if box86 is present { my_context->box86path = strdup(my_context->box64path); - char* p = strrchr(my_context->box86path, '6'); // get the 8 of box86 + char* p = strrchr(my_context->box86path, '6'); // get the 6 of box64 p[0] = '8'; p[1] = '6'; // change 64 to 86 if(!FileExist(my_context->box86path, IS_FILE)) { free(my_context->box86path); @@ -907,17 +907,19 @@ int main(int argc, const char **argv, const char **env) { printf_log(LOG_NONE, "Error: reading elf header of %s, try to launch %s instead\n", my_context->argv[0], x86?"using box86":"natively"); fclose(f); free_contextargv(); - FreeBox64Context(&my_context); FreeCollection(&ld_preload); if(x86) { // duplicate the array to change 1st arg as box86 const char** newargv = (const char**)calloc(argc+1, sizeof(char*)); newargv[0] = my_context->box86path; + FreeBox64Context(&my_context); for(int i=1; i<argc; ++i) newargv[i] = argv[i]; return execvp(newargv[0], (char * const*)newargv); - } else + } else { + FreeBox64Context(&my_context); return execvp(argv[1], (char * const*)(argv+1)); + } printf_log(LOG_NONE, "Failed to execvp: error is %s\n", strerror(errno)); } AddElfHeader(my_context, elf_header); |