Fix invalid read from poor setlocale usage.
authorAlex Baines <alex@abaines.me.uk>
Mon, 03 Oct 2016 15:31:11 +0100
changeset 1051001761b2d701e
parent 10509 f548233b2813
child 10511 8e646a2d1929
Fix invalid read from poor setlocale usage.
src/video/x11/SDL_x11video.c
     1.1 --- a/src/video/x11/SDL_x11video.c	Mon Oct 10 18:28:05 2016 +0200
     1.2 +++ b/src/video/x11/SDL_x11video.c	Mon Oct 03 15:31:11 2016 +0100
     1.3 @@ -399,6 +399,10 @@
     1.4          const char *env_xmods = SDL_getenv("XMODIFIERS");
     1.5          SDL_bool has_dbus_ime_support = SDL_FALSE;
     1.6  
     1.7 +        if (prev_locale) {
     1.8 +            prev_locale = SDL_strdup(prev_locale);
     1.9 +        }
    1.10 +
    1.11          if (prev_xmods) {
    1.12              prev_xmods = SDL_strdup(prev_xmods);
    1.13          }
    1.14 @@ -431,6 +435,10 @@
    1.15          setlocale(LC_ALL, prev_locale);
    1.16          X11_XSetLocaleModifiers(prev_xmods);
    1.17  
    1.18 +        if (prev_locale) {
    1.19 +            SDL_free(prev_locale);
    1.20 +        }
    1.21 +
    1.22          if (prev_xmods) {
    1.23              SDL_free(prev_xmods);
    1.24          }