From 6f46ccdd5ab5c0df527584d7411d9724909cc1ec Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Mon, 6 Jan 2025 10:42:08 +0300 Subject: Fix crash with incorrect argv[0]: rewrite it only if "box64" is present (#2233) --- src/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core.c b/src/core.c index 253b7dc9..a39fa795 100644 --- a/src/core.c +++ b/src/core.c @@ -2142,9 +2142,14 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf { my_context->box86path = box_strdup(my_context->box64path); #ifndef BOX32 - 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)) { + if(strstr(my_context->box86path, "box64")) { + char* p = strrchr(my_context->box86path, '6'); // get the 6 of box64 + p[0] = '8'; p[1] = '6'; // change 64 to 86 + } else { + box_free(my_context->box86path); + my_context->box86path = ResolveFileSoft("box86", &my_context->box64_path); + } + if(my_context->box86path && !FileExist(my_context->box86path, IS_FILE)) { box_free(my_context->box86path); my_context->box86path = NULL; } -- cgit 1.4.1