diff --git a/src/kuroko.c b/src/kuroko.c index 31d71ec..39360b9 100644 --- a/src/kuroko.c +++ b/src/kuroko.c @@ -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 } diff --git a/src/vm.c b/src/vm.c index 63dee33..f8e6808 100644 --- a/src/vm.c +++ b/src/vm.c @@ -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,'/');