From: Christophe CURIS <christophe.cu...@free.fr> As pointed by Coverity, there might be some problems due to sign extension when performing the shifts and ors operations when converting the RImage to the format expected for the WM_ICON property.
This patch try to improve things by using as much as possible unsigned types and by using explicit types conversion instead of counting on the wrong implicit type conversion done by the language. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- WINGs/wwindow.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/WINGs/wwindow.c b/WINGs/wwindow.c index a04ab6a..28844fb 100644 --- a/WINGs/wwindow.c +++ b/WINGs/wwindow.c @@ -217,7 +217,7 @@ static void setMiniwindowTitle(WMWindow * win, const char *title) static void setMiniwindow(WMWindow *win, RImage *image) { WMScreen *scr = win->view->screen; - long *data; + unsigned long *data; int x, y; int o; @@ -232,15 +232,19 @@ static void setMiniwindow(WMWindow *win, RImage *image) for (y = 0; y < image->height; y++) { for (x = 0; x < image->width; x++) { - long pixel; + unsigned long pixel; int offs = (x + y * image->width); - if (image->format == RRGBFormat) - pixel = image->data[offs * 3] << 16 | image->data[offs * 3 + 1] << 8 - | image->data[offs * 3 + 2]; - else - pixel = image->data[offs * 4] << 16 | image->data[offs * 4 + 1] << 8 - | image->data[offs * 4 + 2] | image->data[offs * 4 + 3] << 24; + if (image->format == RRGBFormat) { + pixel = ((unsigned long) image->data[offs * 3 ]) << 16; + pixel |= ((unsigned long) image->data[offs * 3 + 1]) << 8; + pixel |= ((unsigned long) image->data[offs * 3 + 2]); + } else { + pixel = ((unsigned long) image->data[offs * 4 ]) << 16; + pixel |= ((unsigned long) image->data[offs * 4 + 1]) << 8; + pixel |= ((unsigned long) image->data[offs * 4 + 2]); + pixel |= ((unsigned long) image->data[offs * 4 + 3]) << 24; + } data[o++] = pixel; } -- 2.1.1 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.