From 9b08be056ebf99f8bca3e1d3f3f25835534645b5 Mon Sep 17 00:00:00 2001 From: Dorian Wouters Date: Wed, 27 Jan 2016 16:44:14 +0100 Subject: [PATCH] Fix stb_image memory leak --- source/3ds/util.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/3ds/util.cpp b/source/3ds/util.cpp index f48af88..8bf9fb7 100644 --- a/source/3ds/util.cpp +++ b/source/3ds/util.cpp @@ -58,12 +58,14 @@ u8* load_image(const char* image, u32 width, u32 height) { if(imgWidth != width || imgHeight != height) { printf("ERROR: Image must be exactly %d x %d in size.\n", width, height); + stbi_image_free(img); return NULL; } if(imgDepth != STBI_rgb_alpha) { printf("ERROR: Decoded image does't match expected format (%d, wanted %d).\n", imgDepth, STBI_rgb_alpha); + stbi_image_free(img); return NULL; }