From 366de9f248ecec1c6c0274be5c9e3c82c95de5a4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 2 Feb 2013 13:18:23 -0500 Subject: [PATCH] Fix a another memory leak in etctool. imgdec = (unsigned char*) malloc(expandedwidth*expandedheight*3); is called before the if statement "if((f=fopen(dstfile,"wb")))" If the file 'f' failed in the if statement, it would never be freed (since "free(imgdec)" was within that if block. --- ext/etcpack/etctool.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/etcpack/etctool.cpp b/ext/etcpack/etctool.cpp index dbe7af8e04..56f2e07dc5 100644 --- a/ext/etcpack/etctool.cpp +++ b/ext/etcpack/etctool.cpp @@ -612,9 +612,10 @@ void compressImageFile(uint8 *img,int width,int height,char *dstfile, int expand printf("\n"); fclose(f); - free(imgdec); - printf("Saved file <%s>.\n",dstfile); + printf("Saved file <%s>.\n",dstfile); } + + free(imgdec); } double calculatePSNR(uint8 *lossyimg, uint8 *origimg, int width, int height)