Fixed crash at startup
authorSam Lantinga <slouken@libsdl.org>
Sat, 03 Dec 2016 09:59:43 -0800
changeset 106765c4eaca2517a
parent 10675 74f932dfdb27
child 10677 9dad1513547b
Fixed crash at startup
src/events/SDL_mouse.c
     1.1 --- a/src/events/SDL_mouse.c	Sat Dec 03 00:40:13 2016 -0800
     1.2 +++ b/src/events/SDL_mouse.c	Sat Dec 03 09:59:43 2016 -0800
     1.3 @@ -45,7 +45,11 @@
     1.4  {
     1.5      SDL_Mouse *mouse = (SDL_Mouse *)userdata;
     1.6  
     1.7 -    mouse->normal_speed_scale = (float)SDL_atof(hint);
     1.8 +    if (hint && *hint) {
     1.9 +        mouse->normal_speed_scale = (float)SDL_atof(hint);
    1.10 +    } else {
    1.11 +        mouse->normal_speed_scale = 1.0f;
    1.12 +    }
    1.13  }
    1.14  
    1.15  static void
    1.16 @@ -53,7 +57,11 @@
    1.17  {
    1.18      SDL_Mouse *mouse = (SDL_Mouse *)userdata;
    1.19  
    1.20 -    mouse->relative_speed_scale = (float)SDL_atof(hint);
    1.21 +    if (hint && *hint) {
    1.22 +        mouse->relative_speed_scale = (float)SDL_atof(hint);
    1.23 +    } else {
    1.24 +        mouse->relative_speed_scale = 1.0f;
    1.25 +    }
    1.26  }
    1.27  
    1.28  /* Public functions */