Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
X11 msgbox: try to protect the existing setlocale() state.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 8, 2012
1 parent b824049 commit 8804e51
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/video/x11/SDL_x11messagebox.c
Expand Up @@ -654,14 +654,23 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
{
int ret;
SDL_MessageBoxDataX11 data;
char *origlocale;

SDL_zero(data);

setlocale(LC_ALL, "");

if ( !SDL_X11_LoadSymbols() )
return -1;

origlocale = setlocale(LC_ALL, NULL);
if (origlocale != NULL) {
origlocale = SDL_strdup(origlocale);
if (origlocale == NULL) {
SDL_OutOfMemory();
return -1;
}
setlocale(LC_ALL, "");
}

/* This code could get called from multiple threads maybe? */
XInitThreads();

Expand All @@ -681,6 +690,12 @@ X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
}

X11_MessageBoxShutdown( &data );

if (origlocale) {
setlocale(LC_ALL, origlocale);
SDL_free(origlocale);
}

return ret;
}

Expand Down

0 comments on commit 8804e51

Please sign in to comment.