Save the error code before doing any other operation

SDL_ClearError() resets the Win32 error code to 0
main
Sam Lantinga 2023-06-05 21:18:49 -07:00
parent 6e7769cde1
commit 17c397f7ec
1 changed files with 3 additions and 3 deletions

View File

@ -255,6 +255,9 @@ static void free_hid_device(hid_device *dev)
static void register_winapi_error_to_buffer(wchar_t **error_buffer, const WCHAR *op)
{
WCHAR system_err_buf[1024];
DWORD error_code = GetLastError();
free(*error_buffer);
*error_buffer = NULL;
@ -268,9 +271,6 @@ static void register_winapi_error_to_buffer(wchar_t **error_buffer, const WCHAR
return;
}
WCHAR system_err_buf[1024];
DWORD error_code = GetLastError();
DWORD system_err_len = FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,