Launcher: Fix UB when failing to launch because resolving the EXE fails

This commit is contained in:
Kovid Goyal 2021-12-22 07:32:28 +05:30
parent e49b20bfa7
commit b965fb4806
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -264,6 +264,7 @@ int main(int argc, char *argv[]) {
FREE_AFTER_FUNCTION const char *lc_ctype = NULL;
#ifdef __APPLE__
lc_ctype = getenv("LC_CTYPE");
if (lc_ctype) lc_ctype = strdup(lc_ctype);
#endif
if (!read_exe_path(exe, sizeof(exe))) return 1;
strncpy(exe_dir_buf, exe, sizeof(exe_dir_buf));
@ -277,7 +278,6 @@ int main(int argc, char *argv[]) {
// Always use UTF-8 mode, see https://github.com/kovidgoyal/kitty/issues/924
Py_UTF8Mode = 1;
#endif
if (lc_ctype) lc_ctype = strdup(lc_ctype);
RunData run_data = {.exe = exe, .exe_dir = exe_dir, .lib_dir = lib, .argc = argc, .argv = argv, .lc_ctype = lc_ctype};
ret = run_embedded(run_data);
return ret;