Fix possible crash on accessing content rect with nullptr surface

This commit is contained in:
Ivan Savenko committed 2025-03-26 15:37:38 +00:00
1 parent 3ca0c7661a
commit 9da598dcaf
1 file changed
+4 -3
+4 -3
View File
@@ -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