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

@@ -205,12 +205,9 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata)
pSDLBtnData = (SDL_MessageBoxButtonData *)messageboxdata->buttons;
ULONG cSDLBtnData = messageboxdata->numbuttons;
PSZ pszTitle = (messageboxdata->title == NULL)? NULL :
OS2_UTF8ToSys((PSZ) messageboxdata->title);
PSZ pszTitle = OS2_UTF8ToSys((PSZ) messageboxdata->title);
ULONG cbTitle = (pszTitle == NULL)? 0 : strlen(pszTitle);
PSZ pszText = (messageboxdata->message == NULL)? NULL :
OS2_UTF8ToSys((PSZ) messageboxdata->message);
PSZ pszText = OS2_UTF8ToSys((PSZ) messageboxdata->message);
ULONG cbText = (pszText == NULL)? 0 : strlen(pszText);
PDLGTEMPLATE pTemplate;