Преглед на файлове

Fix possible crash on accessing content rect with nullptr surface

Ivan Savenko преди 7 месеца
родител
ревизия
9da598dcaf
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      client/renderSDL/SDLImage.cpp

+ 4 - 3
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