1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-03 12:24:17 +01:00

wrlib: fix possible incorrect shifting operations (Coverity #50204, #50205, #50206)

As pointed by Coverity, the shift operation performed for color-to-pixel
transform may not behave as well as expected because of the types used
(Coverity pointing suspicious sign extension because of int type being
involved).

The new code tries to leave no open interpretation to the compiler.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-06-14 19:34:00 +02:00
committed by Carlos R. Mafra
parent 1cd354d796
commit 6505b2f81c

View File

@@ -978,8 +978,9 @@ Bool RGetClosestXColor(RContext * context, const RColor * color, XColor * retCol
gtable = computeTable(gmask);
btable = computeTable(bmask);
retColor->pixel = (rtable[color->red] << roffs) |
(gtable[color->green] << goffs) | (btable[color->blue] << boffs);
retColor->pixel = (((unsigned long) rtable[color->red]) << roffs)
| (((unsigned long) gtable[color->green]) << goffs)
| (((unsigned long) btable[color->blue]) << boffs);
retColor->red = color->red << 8;
retColor->green = color->green << 8;