mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-13 15:23:34 +00:00
SDL_zenitymessagebox.c: Add exit code checking.
Fixes https://github.com/libsdl-org/SDL/issues/14140 Closes https://github.com/libsdl-org/SDL/pull/14146 Co-authored-by: eafton <blox2000@protonmail.com>
This commit is contained in:
@@ -75,6 +75,7 @@ bool SDL_get_zenity_version(int *major, int *minor)
|
||||
|
||||
bool SDL_Zenity_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
|
||||
{
|
||||
int exit_code = -1;
|
||||
int zenity_major = 0, zenity_minor = 0, output_len = 0;
|
||||
int argc = 5, i;
|
||||
const char *argv[5 + 2 /* icon name */ + 2 /* title */ + 2 /* message */ + 2 * MAX_BUTTONS + 1 /* NULL */] = {
|
||||
@@ -158,8 +159,12 @@ bool SDL_Zenity_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||
return false;
|
||||
}
|
||||
if (buttonID) {
|
||||
char *output = SDL_ReadProcess(process, NULL, NULL);
|
||||
if (output) {
|
||||
char *output = SDL_ReadProcess(process, NULL, &exit_code);
|
||||
if (exit_code < 0 || exit_code == 255) {
|
||||
if (output) {
|
||||
SDL_free(output);
|
||||
}
|
||||
} else if (output) {
|
||||
// It likes to add a newline...
|
||||
char *tmp = SDL_strrchr(output, '\n');
|
||||
if (tmp) {
|
||||
@@ -177,9 +182,10 @@ bool SDL_Zenity_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
|
||||
}
|
||||
SDL_free(output);
|
||||
}
|
||||
} else {
|
||||
SDL_WaitProcess(process, true, &exit_code);
|
||||
}
|
||||
SDL_DestroyProcess(process);
|
||||
|
||||
return true;
|
||||
return !(exit_code < 0 || exit_code == 255);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user