summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/imagehelper.cpp3
-rw-r--r--src/resources/map/mapitem.cpp15
-rw-r--r--src/resources/mapreader.cpp6
-rw-r--r--src/resources/openglimagehelper.cpp6
-rw-r--r--src/resources/resourcemanager.h2
-rw-r--r--src/resources/sdlimagehelper.cpp2
6 files changed, 21 insertions, 13 deletions
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index e49a738f2..18e415972 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -86,6 +86,9 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye)
tmpImage, &rgba, SDL_SWSURFACE);
MSDL_FreeSurface(tmpImage);
+ if (!surf)
+ return nullptr;
+
uint32_t *const pixels = static_cast<uint32_t *const>(surf->pixels);
const int type = dye.getType();
diff --git a/src/resources/map/mapitem.cpp b/src/resources/map/mapitem.cpp
index f1d045e7f..44f3ec889 100644
--- a/src/resources/map/mapitem.cpp
+++ b/src/resources/map/mapitem.cpp
@@ -164,15 +164,12 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y,
&& mType != MapItemType::EMPTY)
{
Font *const font = gui->getFont();
- if (font)
- {
- const Color &color = userPalette->getColor(UserColorId::BEING);
- font->drawString(graphics,
- color,
- color,
- mName,
- x, y);
- }
+ const Color &color = userPalette->getColor(UserColorId::BEING);
+ font->drawString(graphics,
+ color,
+ color,
+ mName,
+ x, y);
}
BLOCK_END("MapItem::draw")
}
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 54ee95ea5..f2ec5633d 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -497,7 +497,7 @@ inline static void setTile(Map *const map,
const MapLayer::Type &layerType,
MapHeights *const heights,
const int x, const int y,
- const int gid) A_NONNULL(1, 4);
+ const int gid) A_NONNULL(1);
inline static void setTile(Map *const map,
MapLayer *const layer,
@@ -556,9 +556,9 @@ inline static void setTile(Map *const map,
case MapLayer::HEIGHTS:
{
- if (!set)
+ if (!set || !heights)
break;
- if (map->getVersion() >= 2)
+ if (heights && map->getVersion() >= 2)
{
heights->setHeight(x, y, static_cast<uint8_t>(
gid - set->getFirstGid() + 1));
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index ca553a180..bf051fc0c 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -67,6 +67,8 @@ Image *OpenGLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const surf = convertTo32Bit(tmpImage);
MSDL_FreeSurface(tmpImage);
+ if (!surf)
+ return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
const int type = dye.getType();
@@ -291,6 +293,8 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
SDL_Surface *oldImage = tmpImage;
tmpImage = convertSurfaceNormalize(tmpImage, width, height);
+ if (!tmpImage)
+ return nullptr;
const int realWidth = tmpImage->w;
const int realHeight = tmpImage->h;
@@ -438,6 +442,8 @@ void OpenGLImageHelper::copySurfaceToImage(const Image *const image,
SDL_Surface *const oldSurface = surface;
surface = convertSurface(surface, surface->w, surface->h);
+ if (!surface)
+ return;
mglTextureSubImage2D(image->mGLImage,
mTextureType, 0,
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index cb55f4d6e..9d954cf50 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -223,7 +223,7 @@ class ResourceManager final
* Returns an instance of the class, creating one if it does not
* already exist.
*/
- static ResourceManager *getInstance() A_WARN_UNUSED;
+ static ResourceManager *getInstance() RETURNS_NONNULL A_WARN_UNUSED;
/**
* Deletes the class instance if it exists.
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index 38939269f..e0018b868 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -71,6 +71,8 @@ Image *SDLImageHelper::load(SDL_RWops *const rw, Dye const &dye)
SDL_Surface *const surf = MSDL_ConvertSurface(
tmpImage, &rgba, SDL_SWSURFACE);
MSDL_FreeSurface(tmpImage);
+ if (!surf)
+ return nullptr;
uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
const int type = dye.getType();