shithub: cstory

Download patch

ref: f006508232e66f68bd210f10116e7927e6f5693e
parent: 6a0005746978070c86dcac7681db8389c98fd172
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Apr 21 20:13:54 EDT 2020

Sanity check

--- a/src/Bitmap.cpp
+++ b/src/Bitmap.cpp
@@ -21,11 +21,16 @@
 	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)