From 4525c897e242a0594c12afa11cf4633d3b97cb25 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 15 Jan 2020 11:22:00 +0100 Subject: [PATCH] GetImageData() returns NULL if image size is 0 --- src/textures.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textures.c b/src/textures.c index 85063830d..768e1be6b 100644 --- a/src/textures.c +++ b/src/textures.c @@ -457,9 +457,9 @@ void UnloadRenderTexture(RenderTexture2D target) // Get pixel data from image in the form of Color struct array Color *GetImageData(Image image) { + if ((image.width == 0) || (image.height == 0)) return NULL; + Color *pixels = (Color *)RL_MALLOC(image.width*image.height*sizeof(Color)); - - if (pixels == NULL) return pixels; if (image.format >= COMPRESSED_DXT1_RGB) TraceLog(LOG_WARNING, "Pixel data retrieval not supported for compressed image formats"); else