瀏覽代碼

Check return value of VIRTUAL_HWDataForIndex()

Mingjie Shen 2 年之前
父節點
當前提交
bf8c9d2d70
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/joystick/virtual/SDL_virtualjoystick.c

+ 1 - 1
src/joystick/virtual/SDL_virtualjoystick.c

@@ -585,7 +585,7 @@ static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadM
     Uint8 current_button = 0;
     Uint8 current_axis = 0;
 
-    if (hwdata->desc.type != SDL_JOYSTICK_TYPE_GAMEPAD) {
+    if (!hwdata || hwdata->desc.type != SDL_JOYSTICK_TYPE_GAMEPAD) {
         return SDL_FALSE;
     }