wayland: Prevent a possible crash when determining the display for a minimized window

A minimized window may not be associated with any displays, so check that the output array is valid and that there is at least one associated display before dereferencing.

Fixes a crash when attempting to unset fullscreen on a minimized window.
This commit is contained in:
Frank Praznik 2024-06-14 12:25:13 -04:00
parent a98774e62c
commit 41532e84cb
No known key found for this signature in database
1 changed files with 8 additions and 1 deletions

View File

@ -494,9 +494,16 @@ static void FlushFullscreenEvents(SDL_Window *window)
static void Wayland_move_window(SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
SDL_DisplayData *display = wind->outputs[wind->num_outputs - 1];
SDL_DisplayData *display;
SDL_DisplayID *displays;
if (wind->outputs && wind->num_outputs) {
display = wind->outputs[wind->num_outputs - 1];
} else {
/* A window may not be on any displays if minimized. */
return;
}
displays = SDL_GetDisplays(NULL);
if (displays) {
for (int i = 0; displays[i]; ++i) {