瀏覽代碼

Fixed crash when quitting after a joystick has been disconnected on Android

Fixes https://github.com/libsdl-org/SDL/issues/10567
Sam Lantinga 1 年之前
父節點
當前提交
61b024766a
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/joystick/android/SDL_sysjoystick.c

+ 3 - 0
src/joystick/android/SDL_sysjoystick.c

@@ -589,6 +589,9 @@ static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index)
 static int ANDROID_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
 static int ANDROID_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
 {
 {
     SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
     SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
+    if (!item) {
+        return SDL_SetError("Rumble failed, device disconnected");
+    }
     if (!item->can_rumble) {
     if (!item->can_rumble) {
         return SDL_Unsupported();
         return SDL_Unsupported();
     }
     }