Fixed crash when a controller is disconnected while rumble is pending
authorSam Lantinga <slouken@libsdl.org>
Wed, 04 Mar 2020 14:59:44 -0800
changeset 13588668a74d2aec1
parent 13587 9944a0c7c355
child 13589 ed4d8114b4e8
Fixed crash when a controller is disconnected while rumble is pending
src/joystick/hidapi/SDL_hidapi_rumble.c
src/joystick/hidapi/SDL_hidapi_switch.c
     1.1 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c	Wed Mar 04 09:42:10 2020 -0800
     1.2 +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c	Wed Mar 04 14:59:44 2020 -0800
     1.3 @@ -76,7 +76,9 @@
     1.4  
     1.5          if (request) {
     1.6              SDL_LockMutex(request->device->dev_lock);
     1.7 -            hid_write(request->device->dev, request->data, request->size);
     1.8 +            if (request->device->dev) {
     1.9 +                hid_write( request->device->dev, request->data, request->size );
    1.10 +            }
    1.11              SDL_UnlockMutex(request->device->dev_lock);
    1.12              (void)SDL_AtomicDecRef(&request->device->rumble_pending);
    1.13              SDL_free(request);
     2.1 --- a/src/joystick/hidapi/SDL_hidapi_switch.c	Wed Mar 04 09:42:10 2020 -0800
     2.2 +++ b/src/joystick/hidapi/SDL_hidapi_switch.c	Wed Mar 04 14:59:44 2020 -0800
     2.3 @@ -477,7 +477,7 @@
     2.4          return SDL_FALSE;
     2.5      }
     2.6      if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_HighSpeed, NULL, 0, SDL_TRUE)) {
     2.7 -        /* The 8BitDo M30 doesn't respond to this command, but otherwise works correctly */
     2.8 +        /* The 8BitDo M30 and SF30 Pro don't respond to this command, but otherwise work correctly */
     2.9          /*return SDL_FALSE;*/
    2.10      }
    2.11      if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, SDL_TRUE)) {