Fixed crash on Windows if haptic isn't initialized when controllers are added.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 06 Feb 2014 21:26:41 -0500
changeset 8185c2996dc8ef6b
parent 8184 2afb90ff0199
child 8186 a3b4d7e5eb8e
Fixed crash on Windows if haptic isn't initialized when controllers are added.
src/haptic/windows/SDL_syshaptic.c
     1.1 --- a/src/haptic/windows/SDL_syshaptic.c	Thu Feb 06 10:00:45 2014 -0500
     1.2 +++ b/src/haptic/windows/SDL_syshaptic.c	Thu Feb 06 21:26:41 2014 -0500
     1.3 @@ -221,6 +221,10 @@
     1.4      DIDEVCAPS capabilities;
     1.5      SDL_hapticlist_item *item = NULL;
     1.6  
     1.7 +    if (dinput == NULL) {
     1.8 +        return -1;  /* not initialized. We'll pick these up on enumeration if we init later. */
     1.9 +    }
    1.10 +
    1.11      /* Make sure we don't already have it */
    1.12      for (item = SDL_hapticlist; item; item = item->next) {
    1.13          if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
    1.14 @@ -286,6 +290,10 @@
    1.15      SDL_hapticlist_item *item;
    1.16      SDL_hapticlist_item *prev = NULL;
    1.17  
    1.18 +    if (dinput == NULL) {
    1.19 +        return -1;  /* not initialized, ignore this. */
    1.20 +    }
    1.21 +
    1.22      for (item = SDL_hapticlist; item != NULL; item = item->next) {
    1.23          if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) {
    1.24              /* found it, remove it. */