1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

WPrefs: Provide fall-back colour in the case of colour name not found

As reported by Coverity (CID #331571), we did not check the return value of
the call to XParseColor. If the function is given a colour name that it
does not know, we would return an uninitialised colour.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2021-05-16 15:47:06 +02:00
committed by Carlos R. Mafra
parent 816fa00625
commit 29cf48b934

View File

@@ -446,12 +446,18 @@ static void str2rcolor(RContext * rc, const char *name, RColor * color)
{
XColor xcolor;
XParseColor(rc->dpy, rc->cmap, name, &xcolor);
color->alpha = 255;
color->red = xcolor.red >> 8;
color->green = xcolor.green >> 8;
color->blue = xcolor.blue >> 8;
if (XParseColor(rc->dpy, rc->cmap, name, &xcolor) != 0) {
color->alpha = 255;
color->red = xcolor.red >> 8;
color->green = xcolor.green >> 8;
color->blue = xcolor.blue >> 8;
} else {
/* Color Name was not found - Return white instead */
color->alpha = 255;
color->red = 255;
color->green = 255;
color->blue = 255;
}
}
static void dumpRImage(const char *path, RImage * image)