Commit e79f00097a5f49eacb1d5ce19cddb00536fe25bc

Philipp Wiesemann 2016-08-25T22:31:44

Emscripten: Fixed crash if closing removed joystick (thanks, Sylvain!).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c
index c3becd2..c3edf49 100644
--- a/src/joystick/emscripten/SDL_sysjoystick.c
+++ b/src/joystick/emscripten/SDL_sysjoystick.c
@@ -378,7 +378,9 @@ void
 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
 {
     SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
-    item->joystick = NULL;
+    if (item) {
+        item->joystick = NULL;
+    }
 }
 
 /* Function to perform any system-specific joystick related cleanup */