From d9e3972acb84e26e7b87475c315b59885e04b342 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Mon, 3 Oct 2016 15:31:11 +0100 Subject: [PATCH] Fix invalid read from poor setlocale usage. --- src/video/x11/SDL_x11video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 724b5fb38..e658ac0f4 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -399,6 +399,10 @@ X11_VideoInit(_THIS) const char *env_xmods = SDL_getenv("XMODIFIERS"); SDL_bool has_dbus_ime_support = SDL_FALSE; + if (prev_locale) { + prev_locale = SDL_strdup(prev_locale); + } + if (prev_xmods) { prev_xmods = SDL_strdup(prev_xmods); } @@ -431,6 +435,10 @@ X11_VideoInit(_THIS) setlocale(LC_ALL, prev_locale); X11_XSetLocaleModifiers(prev_xmods); + if (prev_locale) { + SDL_free(prev_locale); + } + if (prev_xmods) { SDL_free(prev_xmods); }