From b62f86bf45de4b5e0afd70e8d274521d1c15b318 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 16 Jan 2010 17:48:14 +0000 Subject: [PATCH] Fixed double free when loading 24b image. Yves, it is not needed to check if a pointer is NULL before freeing it, free(NULL) is okay and will not crash. However, each time you free something, you should put it back to NULL : -It makes sure the program will crash on next access to it (even if the memory chunk is reallocated) -It makes it easier to debug things, a NULL pointer is freed data. If you can't gt used to it, create a Free macro that does the NULLification for you... git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1259 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- loadsave.c | 1 + 1 file changed, 1 insertion(+) diff --git a/loadsave.c b/loadsave.c index 91535eca..12e3d0e7 100644 --- a/loadsave.c +++ b/loadsave.c @@ -692,6 +692,7 @@ void Load_image(T_IO_Context *context) } } free(context->Buffer_image_24b); + context->Buffer_image_24b = NULL; } if (context->Type == CONTEXT_MAIN_IMAGE)