From eda684142050cf54b86f62e147edee921c65fa7e Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 1 Jun 2020 17:23:46 +0200 Subject: [PATCH] gallium/os: call "ANSI" version of GetCommandLine The GetCommandLine API comes in two versions, GetCommandLineA (which returns "ANSI" results), and GetCommandLineW which returns UTF-16 ("WIDE") results. Then finally, windows.h provides a wrapper-macro that defines GetCommandLine to either of the two, based on the setting of the UNICODE macro. More information about this mechanism can be found here: https://docs.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api For some reason, the UNICODE macro is set during build, even if we're not explicitly setting it. This leads to us trying to cast a UTF-16 result to a char-pointer, which is obviously not going to do the right thing. So let's be defensive, and just call GetCommandLineA directly instead. This avoids us depending on the setting of the UNICODE-macro in the first place. Acked-by: Alyssa Rosenzweig Part-of: --- src/gallium/auxiliary/os/os_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c index a2c859b78b3..f2721a0fb52 100644 --- a/src/gallium/auxiliary/os/os_process.c +++ b/src/gallium/auxiliary/os/os_process.c @@ -113,7 +113,7 @@ boolean os_get_command_line(char *cmdline, size_t size) { #if defined(PIPE_OS_WINDOWS) - const char *args = GetCommandLine(); + const char *args = GetCommandLineA(); if (args) { strncpy(cmdline, args, size); // make sure we terminate the string -- 2.30.2