From 99400735303826db7fa0ed1f836abc157cb965e6 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Tue, 20 May 2014 21:46:38 +0200 Subject: [PATCH] WMaker: fix memory leak in the switchpanel backgroung image (Coverity #50131) As pointed by Coverity, if the target width or height for the center ended being <= 0 then the image created to contain the generated assemblage would be leaked. Signed-off-by: Christophe CURIS --- src/switchpanel.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/switchpanel.c b/src/switchpanel.c index 16083658..e7bee409 100644 --- a/src/switchpanel.c +++ b/src/switchpanel.c @@ -239,19 +239,10 @@ static void scrollIcons(WSwitchPanel *panel, int delta) */ static RImage *assemblePuzzleImage(RImage **images, int width, int height) { - RImage *img = RCreateImage(width, height, 1); + RImage *img; RImage *tmp; int tw, th; RColor color; - if (!img) - return NULL; - - color.red = 0; - color.green = 0; - color.blue = 0; - color.alpha = 255; - - RFillImage(img, &color); tw = width - images[0]->width - images[2]->width; th = height - images[0]->height - images[6]->height; @@ -259,6 +250,16 @@ static RImage *assemblePuzzleImage(RImage **images, int width, int height) if (tw <= 0 || th <= 0) return NULL; + img = RCreateImage(width, height, 1); + if (!img) + return NULL; + + color.red = 0; + color.green = 0; + color.blue = 0; + color.alpha = 255; + RFillImage(img, &color); + /* top */ if (tw > 0) { tmp = RSmoothScaleImage(images[1], tw, images[1]->height); -- 2.11.4.GIT