From: Christophe CURIS <christophe.cu...@free.fr>

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 <christophe.cu...@free.fr>
---
 src/switchpanel.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/switchpanel.c b/src/switchpanel.c
index 1608365..e7bee40 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);
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to