From b7da899674bc92cbe1926825058f0ffc2afab522 Mon Sep 17 00:00:00 2001 From: AllyTally Date: Wed, 23 Aug 2023 20:10:41 -0300 Subject: [PATCH] Fix UB where image loading fails in certain cases --- desktop_version/src/GraphicsResources.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/GraphicsResources.cpp b/desktop_version/src/GraphicsResources.cpp index 2fb1be0a..0e7cf965 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -21,7 +21,9 @@ extern "C" static SDL_Surface* LoadImageRaw(const char* filename, unsigned char** data) { - //Temporary storage for the image that's loaded + *data = NULL; + + // Temporary storage for the image that's loaded SDL_Surface* loadedImage = NULL; unsigned int width, height; @@ -84,7 +86,6 @@ SDL_Surface* LoadImageSurface(const char* filename) if (optimizedImage == NULL) { - VVV_free(data); vlog_error("Image not found: %s", filename); SDL_assert(0 && "Image not found! See stderr."); }