From a9a6ccb1038f0baabff9990499fdf03a2b44c8fc Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sun, 2 Nov 2025 14:03:42 +0000 Subject: [PATCH] Guard autoupdater more completely --- code/sys/sys_autoupdater.c | 34 ++++++++++++++-------------------- code/sys/sys_local.h | 4 ++++ code/sys/sys_main.c | 3 ++- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/code/sys/sys_autoupdater.c b/code/sys/sys_autoupdater.c index 2f59e071..e9b37f7b 100644 --- a/code/sys/sys_autoupdater.c +++ b/code/sys/sys_autoupdater.c @@ -17,28 +17,24 @@ is licensed under the GPLv2. Do not mingle code, please! # include # include -#endif void Sys_LaunchAutoupdater(int argc, char **argv) { -#ifdef USE_AUTOUPDATER #ifdef _WIN32 - { - /* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */ - PROCESS_INFORMATION procinfo; - STARTUPINFO startinfo; - char cmdline[128]; - memset(&procinfo, '\0', sizeof (procinfo)); - memset(&startinfo, '\0', sizeof (startinfo)); - startinfo.cb = sizeof (startinfo); - sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId()); + /* We don't need the Unix pipe() tapdance here because Windows lets children wait on parent processes. */ + PROCESS_INFORMATION procinfo; + STARTUPINFO startinfo; + char cmdline[128]; + memset(&procinfo, '\0', sizeof (procinfo)); + memset(&startinfo, '\0', sizeof (startinfo)); + startinfo.cb = sizeof (startinfo); + sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId()); - if (CreateProcessA(AUTOUPDATER_BIN, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startinfo, &procinfo)) - { - /* close handles now so child cleans up immediately if nothing to do */ - CloseHandle(procinfo.hProcess); - CloseHandle(procinfo.hThread); - } + if (CreateProcessA(AUTOUPDATER_BIN, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startinfo, &procinfo)) + { + /* close handles now so child cleans up immediately if nothing to do */ + CloseHandle(procinfo.hProcess); + CloseHandle(procinfo.hThread); } #else int updater_pipes[2]; @@ -79,8 +75,6 @@ void Sys_LaunchAutoupdater(int argc, char **argv) } } #endif -#endif - - (void) argc; (void) argv; /* possibly unused. Pacify compilers. */ } +#endif /* USE_AUTOUPDATER */ diff --git a/code/sys/sys_local.h b/code/sys/sys_local.h index 69c164c5..1c27faac 100644 --- a/code/sys/sys_local.h +++ b/code/sys/sys_local.h @@ -73,3 +73,7 @@ qboolean Sys_OpenFolderInPlatformFileManager( const char *path ); #ifdef PROTOCOL_HANDLER char *Sys_ParseProtocolUri( const char *uri ); #endif + +#ifdef USE_AUTOUPDATER +void Sys_LaunchAutoupdater(int argc, char **argv); +#endif diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index d7f53983..dd64fead 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -790,8 +790,9 @@ int main( int argc, char **argv ) char *protocolCommand = NULL; #endif - extern void Sys_LaunchAutoupdater(int argc, char **argv); +#ifdef USE_AUTOUPDATER Sys_LaunchAutoupdater(argc, argv); +#endif #ifndef DEDICATED // SDL version check