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:
committed by
Carlos R. Mafra
parent
7d48855077
commit
9940073530
@@ -239,10 +239,18 @@ 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;
|
||||
|
||||
tw = width - images[0]->width - images[2]->width;
|
||||
th = height - images[0]->height - images[6]->height;
|
||||
|
||||
if (tw <= 0 || th <= 0)
|
||||
return NULL;
|
||||
|
||||
img = RCreateImage(width, height, 1);
|
||||
if (!img)
|
||||
return NULL;
|
||||
|
||||
@@ -250,15 +258,8 @@ static RImage *assemblePuzzleImage(RImage **images, int width, int height)
|
||||
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;
|
||||
|
||||
if (tw <= 0 || th <= 0)
|
||||
return NULL;
|
||||
|
||||
/* top */
|
||||
if (tw > 0) {
|
||||
tmp = RSmoothScaleImage(images[1], tw, images[1]->height);
|
||||
|
||||
Reference in New Issue
Block a user