From 2bb5d19697ef18d5c758ffa6162c50cfed944064 Mon Sep 17 00:00:00 2001 From: Amarnath Valluri Date: Fri, 10 Jun 2016 13:58:21 +0300 Subject: [PATCH] libutils/mipmap.c: Fixed possible memory leak In case of malloc() failure memory allocated for both 'srcImage' and 'dstImage' is leaked. Signed-off-by: Amarnath Valluri --- src/libutil/mipmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libutil/mipmap.c b/src/libutil/mipmap.c index c475c96..1f718a6 100644 --- a/src/libutil/mipmap.c +++ b/src/libutil/mipmap.c @@ -4509,7 +4509,11 @@ static int gluBuild2DMipmapLevelsCore(GLenum target, GLint internalFormat, glPixelStorei(GL_UNPACK_SKIP_PIXELS, psm.unpack_skip_pixels); glPixelStorei(GL_UNPACK_ROW_LENGTH, psm.unpack_row_length); glPixelStorei(GL_UNPACK_SWAP_BYTES, psm.unpack_swap_bytes); - return GLU_OUT_OF_MEMORY; + free(srcImage); /*if you get to here, a srcImage has always been malloc'ed*/ + if (dstImage) { /* if it's non-rectangular and only 1 level */ + free(dstImage); + } + return GLU_OUT_OF_MEMORY; } /* copy image from srcImage into newMipmapImage by rows */ -- 2.5.0