From 9da598dcaf3cf527bce71bf94d5f9dc76800b373 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 16 Mar 2025 17:34:15 +0000 Subject: [PATCH] Fix possible crash on accessing content rect with nullptr surface --- client/renderSDL/SDLImage.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/renderSDL/SDLImage.cpp b/client/renderSDL/SDLImage.cpp index 8722ecd41..85a10d1c2 100644 --- a/client/renderSDL/SDLImage.cpp +++ b/client/renderSDL/SDLImage.cpp @@ -352,9 +352,10 @@ Rect SDLImageShared::contentRect() const if(upscalingInProgress) throw std::runtime_error("Attempt to access images that is still being loaded!"); - auto tmpMargins = margins; - auto tmpSize = Point(surf->w, surf->h); - return Rect(tmpMargins, tmpSize); + if (!surf) + return Rect(); + + return Rect(margins, Point(surf->w, surf->h)); } const SDL_Palette * SDLImageShared::getPalette() const