Browse Source

Fix crash on attempt to flip empty image

Ivan Savenko 10 months ago
parent
commit
698d43e195
1 changed files with 6 additions and 0 deletions
  1. 6 0
      client/renderSDL/SDLImage.cpp

+ 6 - 0
client/renderSDL/SDLImage.cpp

@@ -404,6 +404,9 @@ std::shared_ptr<IImage> SDLImageShared::createImageReference(EImageBlitMode mode
 
 std::shared_ptr<const ISharedImage> SDLImageShared::horizontalFlip() const
 {
+	if (!surf)
+		return shared_from_this();
+
 	SDL_Surface * flipped = CSDL_Ext::horizontalFlip(surf);
 	auto ret = std::make_shared<SDLImageShared>(flipped, preScaleFactor);
 	ret->fullSize = fullSize;
@@ -416,6 +419,9 @@ std::shared_ptr<const ISharedImage> SDLImageShared::horizontalFlip() const
 
 std::shared_ptr<const ISharedImage> SDLImageShared::verticalFlip() const
 {
+	if (!surf)
+		return shared_from_this();
+
 	SDL_Surface * flipped = CSDL_Ext::verticalFlip(surf);
 	auto ret = std::make_shared<SDLImageShared>(flipped, preScaleFactor);
 	ret->fullSize = fullSize;