fix bug #5253: handle NULL title or message fields in SDL_MessageBoxData

- SDL_video.c (SDL_ShowMessageBox): replace messageboxdata, set title
  or message field to "" if either of them is NULL.
- SDL_video.c (SDL_ShowSimpleMessageBox):  set title or message to ""
  if either of them is NULL for EMSCRIPTEN builds.
- SDL_bmessagebox.cc: add empty string check along with NULL check for
  title and message fields.
- SDL_windowsmessagebox.c (AddDialogString): remove NULL string check
- SDL_windowsmessagebox.c (AddDialogControl):  add empty string check
  along with the NULL check.
- SDL_x11messagebox.c: revert commit 677c4cd68069
- SDL_os2messagebox.c: revert commit 2c2a489d76e7
- test/testmessage.c: Add NULL title and NULL message tests.
This commit is contained in:
Ozkan Sezer
2020-12-10 11:20:56 +03:00
parent eec73dfd20
commit f1cab8aea6
6 changed files with 34 additions and 16 deletions

View File

@@ -256,10 +256,6 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string)
size_t count;
SDL_bool status;
if (!string) {
string = "";
}
wstring = WIN_UTF8ToString(string);
if (!wstring) {
return SDL_FALSE;
@@ -318,7 +314,7 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style,
if (!AddDialogData(dialog, &type, sizeof(type))) {
return SDL_FALSE;
}
if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL)) {
if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL && caption[0])) {
if (!AddDialogString(dialog, caption)) {
return SDL_FALSE;
}