소스 검색

Fixed race condition at startup that could cause a crash in the XInput driver

(cherry picked from commit 6d7c211fafd5404e6d10a143ab4c443ed9e61b5a)
Sam Lantinga 1 년 전
부모
커밋
5aadfd4eaf
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      src/joystick/windows/SDL_xinputjoystick.c

+ 5 - 3
src/joystick/windows/SDL_xinputjoystick.c

@@ -65,11 +65,13 @@ SDL_bool SDL_XINPUT_Enabled(void)
 
 int SDL_XINPUT_JoystickInit(void)
 {
-    s_bXInputEnabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
+    SDL_bool enabled = SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE);
 
-    if (s_bXInputEnabled && WIN_LoadXInputDLL() < 0) {
-        s_bXInputEnabled = SDL_FALSE; /* oh well. */
+    if (enabled && WIN_LoadXInputDLL() < 0) {
+        enabled = SDL_FALSE; /* oh well. */
     }
+    s_bXInputEnabled = enabled;
+
     return 0;
 }