Fixed the Win32 startup path initialization in fe_args to avoid blindly calling g_path_get_dirname(argv[0]) when argv may be missing/invalid in subsystem:windows launch contexts (like URL handler launches).

Updated logic to prefer g_win32_get_package_installation_directory_of_module(NULL) first, and only fall back to argv[0] when argc > 0, argv != NULL, and argv[0] != NULL, preventing null/invalid pointer access during startup.
This commit is contained in:
2026-02-26 11:38:08 -07:00
parent e8dbe06f01
commit 324aeab8c9

View File

@@ -410,6 +410,11 @@ fe_args (int argc, char *argv[])
/* of the exe. */
{
g_free (win32_argv0_dir);
/* In subsystem:windows builds, argv can be absent/invalid depending on
* launch context (e.g. shell URL handlers). Prefer the module path,
* then only fall back to argv[0] when it is available. */
win32_argv0_dir = g_win32_get_package_installation_directory_of_module (NULL);
if (win32_argv0_dir == NULL && argc > 0 && argv != NULL && argv[0] != NULL)
win32_argv0_dir = g_path_get_dirname (argv[0]);
if (win32_argv0_dir)
chdir (win32_argv0_dir);