From d30432ea31523a64b900b9b3086636dc0317dbba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 18 Nov 2023 23:31:16 +0100 Subject: [PATCH] win32: don't jump over variable init with goto Those variables are accessed after jump. --- input/ipc-win.c | 3 ++- osdep/subprocess-win.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/input/ipc-win.c b/input/ipc-win.c index 8db6705f3f..b0200eafc3 100644 --- a/input/ipc-win.c +++ b/input/ipc-win.c @@ -360,6 +360,7 @@ static MP_THREAD_VOID ipc_thread(void *p) mp_thread_set_name("ipc/named-pipe"); MP_VERBOSE(arg, "Starting IPC master\n"); + OVERLAPPED ol = {0}; SECURITY_ATTRIBUTES sa = { .nLength = sizeof sa, .lpSecurityDescriptor = create_restricted_sd(), @@ -369,7 +370,7 @@ static MP_THREAD_VOID ipc_thread(void *p) goto done; } - OVERLAPPED ol = { .hEvent = CreateEventW(NULL, TRUE, TRUE, NULL) }; + ol = (OVERLAPPED){ .hEvent = CreateEventW(NULL, TRUE, TRUE, NULL) }; if (!ol.hEvent) { MP_ERR(arg, "Couldn't create event"); goto done; diff --git a/osdep/subprocess-win.c b/osdep/subprocess-win.c index bb3527eaa6..5413b24bc4 100644 --- a/osdep/subprocess-win.c +++ b/osdep/subprocess-win.c @@ -253,6 +253,8 @@ void mp_subprocess2(struct mp_subprocess_opts *opts, }, }; + PROCESS_INFORMATION pi = {0}; + for (int n = 0; n < opts->num_fds; n++) { if (opts->fds[n].fd >= crt_fd_max) { // Target FD is too big to fit in the CRT FD array @@ -396,7 +398,6 @@ void mp_subprocess2(struct mp_subprocess_opts *opts, } DWORD flags = CREATE_UNICODE_ENVIRONMENT | EXTENDED_STARTUPINFO_PRESENT; - PROCESS_INFORMATION pi = {0}; // Specify which handles are inherited by the subprocess. If this isn't // specified, the subprocess inherits all inheritable handles, which could