From d4794cc714dd643d20302da2cfb91b09e4c74542 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 11 Mar 2024 11:17:45 -0700 Subject: [PATCH] Fix crash in SDL_UpdateFullscreenMode calling SetWindowFullscreen with a null display - This mirrors the check above for fullscreen=true in the unlikely case where there is no primary display detected --- src/video/SDL_video.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 6cdcf8442..eff8e398e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1765,7 +1765,10 @@ int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen, SDL_bool c if (commit) { int ret = 0; if (_this->SetWindowFullscreen) { - ret = _this->SetWindowFullscreen(_this, window, display ? display : SDL_GetVideoDisplayForFullscreenWindow(window), SDL_FALSE); + SDL_VideoDisplay *full_screen_display = display ? display : SDL_GetVideoDisplayForFullscreenWindow(window); + if (full_screen_display) { + ret = _this->SetWindowFullscreen(_this, window, full_screen_display, SDL_FALSE); + } } else { resized = SDL_TRUE; }