From 5e142f81a9fd30b1b360032779ff1cc9be83aa84 Mon Sep 17 00:00:00 2001 From: DRC Date: Mon, 9 Apr 2012 15:26:46 -0500 Subject: [PATCH] Fix memory leak in TurboVNC Note that the memory leak was only occurring with the colorspace emulation code, which is only active when using regular libjpeg (not libjpeg-turbo.) Diagnosed by Christian Beier, using valgrind. Signed-off-by: Johannes Schindelin --- common/turbojpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/turbojpeg.c b/common/turbojpeg.c index c145338..11168a2 100644 --- a/common/turbojpeg.c +++ b/common/turbojpeg.c @@ -601,7 +601,7 @@ DLLEXPORT int DLLCALL tjCompress2(tjhandle handle, unsigned char *srcBuf, bailout: if(cinfo->global_state>CSTATE_START) jpeg_abort_compress(cinfo); #ifndef JCS_EXTENSIONS - if(rgbBuf && rgbBuf!=srcBuf) free(rgbBuf); + if(rgbBuf) free(rgbBuf); #endif if(row_pointer) free(row_pointer); return retval; @@ -835,7 +835,7 @@ DLLEXPORT int DLLCALL tjDecompress2(tjhandle handle, unsigned char *jpegBuf, bailout: if(dinfo->global_state>DSTATE_START) jpeg_abort_decompress(dinfo); #ifndef JCS_EXTENSIONS - if(rgbBuf && rgbBuf!=dstBuf) free(rgbBuf); + if(rgbBuf) free(rgbBuf); #endif if(row_pointer) free(row_pointer); return retval;