mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-10 07:50:19 +00:00
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:
@@ -410,7 +410,12 @@ fe_args (int argc, char *argv[])
|
|||||||
/* of the exe. */
|
/* of the exe. */
|
||||||
{
|
{
|
||||||
g_free (win32_argv0_dir);
|
g_free (win32_argv0_dir);
|
||||||
win32_argv0_dir = g_path_get_dirname (argv[0]);
|
/* 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)
|
if (win32_argv0_dir)
|
||||||
chdir (win32_argv0_dir);
|
chdir (win32_argv0_dir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user