Răsfoiți Sursa

Save the error code before doing any other operation

SDL_ClearError() resets the Win32 error code to 0
Sam Lantinga 1 an în urmă
părinte
comite
17c397f7ec
1 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 3 3
      src/hidapi/windows/hid.c

+ 3 - 3
src/hidapi/windows/hid.c

@@ -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,