From a8450dc9cf06c6bb87170181901fc1e54c040d9d Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 7 Jan 2007 20:30:22 +0000 Subject: [PATCH] fixed mem leaks --- lib/png.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/png.c b/lib/png.c index f517151..abb5a3e 100644 --- a/lib/png.c +++ b/lib/png.c @@ -545,8 +545,9 @@ int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata) } printf("\n");*/ } - if(data) - free(data); + if(data) { + free(data); data=0; + } } if(!zimagedata || uncompress(imagedata, &imagedatalen, zimagedata, zimagedatalen) != Z_OK) { @@ -602,6 +603,7 @@ int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata) } } free(old); + free(imagedata); } else if(header.mode == 6 || header.mode == 2) { int i,s=0; int x,y; @@ -637,6 +639,7 @@ int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata) else // header.mode = 2 applyfilter3(mode, src, old, dest, header.width); } + free(imagedata); } else if(header.mode == 0 || header.mode == 3) { COL*rgba = 0; U8*tmpline = (U8*)malloc(header.width+1); @@ -726,6 +729,7 @@ int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata) free(tmpline); free(destline); free(rgba); + free(imagedata); } else { printf("expected PNG mode to be 2, 3 or 6 (is:%d)\n", header.mode); return 0; -- 1.7.10.4