1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-23 06:38:05 +01:00

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 <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-05-20 21:46:38 +02:00
committed by Carlos R. Mafra
parent 7d48855077
commit 9940073530

View File

@@ -239,19 +239,10 @@ static void scrollIcons(WSwitchPanel *panel, int delta)
*/ */
static RImage *assemblePuzzleImage(RImage **images, int width, int height) static RImage *assemblePuzzleImage(RImage **images, int width, int height)
{ {
RImage *img = RCreateImage(width, height, 1); RImage *img;
RImage *tmp; RImage *tmp;
int tw, th; int tw, th;
RColor color; 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; tw = width - images[0]->width - images[2]->width;
th = height - images[0]->height - images[6]->height; 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) if (tw <= 0 || th <= 0)
return NULL; 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 */ /* top */
if (tw > 0) { if (tw > 0) {
tmp = RSmoothScaleImage(images[1], tw, images[1]->height); tmp = RSmoothScaleImage(images[1], tw, images[1]->height);