From 806784e194c891feee064d4b75e17426f5dc9cd2 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Thu, 15 Nov 2012 01:30:33 +0100 Subject: [PATCH] Fixed wrong count to release temporary memory As found by Rodolfo, it looks like there could be memory leak in the function 'RSmoothScaleImage' because it reserveda given number of memory blocs but used another count to free them after use. This patch uses the same count for release as it seems this variable is not modified in between. Took the opportunity as Rodolfo proposed to convert a global variable to a local variable - this global definition seems incorrect. --- wrlib/scale.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wrlib/scale.c b/wrlib/scale.c index 82ed57e8..c5b5cafd 100644 --- a/wrlib/scale.c +++ b/wrlib/scale.c @@ -278,14 +278,13 @@ typedef struct { CONTRIB *p; /* pointer to list of contributions */ } CLIST; -CLIST *contrib; /* array of contribution lists */ - /* clamp the input to the specified range */ #define CLAMP(v,l,h) ((v)<(l) ? (l) : (v) > (h) ? (h) : v) /* return of calloc is not checked if NULL in the function below! */ RImage *RSmoothScaleImage(RImage * src, unsigned new_width, unsigned new_height) { + CLIST *contrib; /* array of contribution lists */ RImage *tmp; /* intermediate image */ double xscale, yscale; /* zoom scale factors */ int i, j, k; /* loop variables */ @@ -381,7 +380,7 @@ RImage *RSmoothScaleImage(RImage * src, unsigned new_width, unsigned new_height) } /* free the memory allocated for horizontal filter weights */ - for (i = 0; i < tmp->width; ++i) { + for (i = 0; i < new_width; ++i) { free(contrib[i].p); } free(contrib); -- 2.11.4.GIT