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

From 61b024766a0688fcbd3e392274d31b48128f2d64 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 20 Aug 2024 07:25:19 -0700
Subject: [PATCH] Fixed crash when quitting after a joystick has been
 disconnected on Android

Fixes https://github.com/libsdl-org/SDL/issues/10567
---
 src/joystick/android/SDL_sysjoystick.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c
index 60e6be04ca7d8..da1a109f5aac5 100644
--- a/src/joystick/android/SDL_sysjoystick.c
+++ b/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)
 {
     SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
+    if (!item) {
+        return SDL_SetError("Rumble failed, device disconnected");
+    }
     if (!item->can_rumble) {
         return SDL_Unsupported();
     }