I'm not really sure why that was failing, but let's copy the binpath just in case...

This commit is contained in:
K. Lange 2021-02-16 08:50:17 +09:00
parent 3cef9d05e8
commit 9ef1d2ed66
2 changed files with 2 additions and 2 deletions

View File

@ -311,7 +311,7 @@ static void findInterpreter(char * argv[]) {
}
}
if (binpath) {
vm.binpath = binpath;
vm.binpath = strdup(binpath);
} /* Else, give up at this point and just don't attach it at all. */
#endif
}

View File

@ -1193,7 +1193,7 @@ void krk_initVM(int flags) {
krk_attachNamedValue(&vm.system->fields, "module_paths", module_paths);
krk_writeValueArray(AS_LIST(module_paths), OBJECT_VAL(S("./")));
if (vm.binpath) {
krk_attachNamedObject(&vm.system->fields, "executable_path", (KrkObj*)krk_takeString(vm.binpath, strlen(vm.binpath)));
krk_attachNamedObject(&vm.system->fields, "executable_path", (KrkObj*)krk_copyString(vm.binpath, strlen(vm.binpath)));
char * dir = strdup(vm.binpath);
#ifndef _WIN32
char * slash = strrchr(dir,'/');