From f006508232e66f68bd210f10116e7927e6f5693e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 22 Apr 2020 00:13:54 +0100 Subject: [PATCH] Sanity check --- src/Bitmap.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Bitmap.cpp b/src/Bitmap.cpp index 10947328..79b4eeeb 100644 --- a/src/Bitmap.cpp +++ b/src/Bitmap.cpp @@ -21,11 +21,16 @@ unsigned char* DecodeBitmapFromFile(const char *path, unsigned int *width, unsig size_t file_size; unsigned char *file_buffer = LoadFileToMemory(path, &file_size); - unsigned char *pixel_buffer = stbi_load_from_memory(file_buffer, file_size, (int*)width, (int*)height, NULL, 3); + if (file_buffer != NULL) + { + unsigned char *pixel_buffer = stbi_load_from_memory(file_buffer, file_size, (int*)width, (int*)height, NULL, 3); - free(file_buffer); + free(file_buffer); - return pixel_buffer; + return pixel_buffer; + } + + return NULL; } void FreeBitmap(unsigned char *buffer)