From f71c71fe42756e18e41c7e6ee531f1acc72815ca Mon Sep 17 00:00:00 2001 From: Nat Goodspeed <nat@lindenlab.com> Date: Thu, 25 Oct 2018 11:24:06 -0400 Subject: [PATCH] DRTVWR-476: Fix _open_osfhandle() param from long to intptr_t. The Microsoft _open_osfhandle() opens a HANDLE to produce a C-style int file descriptor suitable for passing to _fdopen(). We used to cast the HANDLEs returned by GetStdHandle() to long to pass to _open_osfhandle(). Since HANDLE is an alias for a pointer, this no longer works. Fortunately _open_osfhandle() now accepts intptr_t, so we can change the relevant GetStdHandle() calls. (But why not simply accept HANDLE in the first place?) --- indra/newview/llappviewerwin32.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index d208e135bbb..9a8a5f16bb8 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -504,7 +504,7 @@ const S32 MAX_CONSOLE_LINES = 500; static bool create_console() { int h_con_handle; - long l_std_handle; + intptr_t l_std_handle; CONSOLE_SCREEN_BUFFER_INFO coninfo; FILE *fp; @@ -518,7 +518,7 @@ static bool create_console() SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); // redirect unbuffered STDOUT to the console - l_std_handle = (long)GetStdHandle(STD_OUTPUT_HANDLE); + l_std_handle = reinterpret_cast<decltype(l_std_handle)>(GetStdHandle(STD_OUTPUT_HANDLE)); h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); if (h_con_handle == -1) { @@ -532,7 +532,7 @@ static bool create_console() } // redirect unbuffered STDIN to the console - l_std_handle = (long)GetStdHandle(STD_INPUT_HANDLE); + l_std_handle = reinterpret_cast<decltype(l_std_handle)>(GetStdHandle(STD_INPUT_HANDLE)); h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); if (h_con_handle == -1) { @@ -546,7 +546,7 @@ static bool create_console() } // redirect unbuffered STDERR to the console - l_std_handle = (long)GetStdHandle(STD_ERROR_HANDLE); + l_std_handle = reinterpret_cast<decltype(l_std_handle)>(GetStdHandle(STD_ERROR_HANDLE)); h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT); if (h_con_handle == -1) { -- GitLab