summaryrefslogtreecommitdiff
path: root/hw/xwin/wincursor.c
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2013-08-10 11:55:23 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2013-08-30 12:58:49 +0100
commit784c006adb22c6693ad30dd0b1b05369cfaa7b5e (patch)
tree0e43bcaea6f5db96e7d3b503d780dd2ffccf94ad /hw/xwin/wincursor.c
parent41d03c9ccce665b919b180bbb819b78c750aa325 (diff)
hw/xwin: Fix -Warray-bounds warning in winXCursorToHCURSOR()
Rewrite winXCursorToHCURSOR() so access to BITMAPINFO bmiColors member doesn't trigger an -Warray-bounds warning. Note that the underlying storage is allocated as a BITMAPV4HEADER, so has sufficent room for the extra RGBQUADs bmiColors after the BITMAPINFO bmiHeader. wincursor.c: In function 'winSetCursor': wincursor.c:293:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:294:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:295:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:296:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:297:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:298:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:299:24: error: array subscript is above array bounds [-Werror=array-bounds] wincursor.c:300:24: error: array subscript is above array bounds [-Werror=array-bounds] Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk> Reviewed-by: Colin Harrison <colin.harrison@virgin.net> Reviewed-by: Marc Haesen <marha@users.sourceforge.net>
Diffstat (limited to 'hw/xwin/wincursor.c')
-rw-r--r--hw/xwin/wincursor.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/hw/xwin/wincursor.c b/hw/xwin/wincursor.c
index 2962d06ad..285e1bcc2 100644
--- a/hw/xwin/wincursor.c
+++ b/hw/xwin/wincursor.c
@@ -273,9 +273,12 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
} /* End if-truecolor-icon */
if (!lpBits) {
+ RGBQUAD *pbmiColors;
/* Bicolor, use a palettized DIB */
WIN_DEBUG_MSG("winLoadCursor: Trying two color cursor\n");
pbmi = (BITMAPINFO *) &bi;
+ pbmiColors = &(pbmi->bmiColors[0]);
+
memset(pbmi, 0, sizeof(BITMAPINFOHEADER));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
@@ -286,18 +289,19 @@ winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
pbmi->bmiHeader.biSizeImage = 0;
pbmi->bmiHeader.biClrUsed = 3;
pbmi->bmiHeader.biClrImportant = 3;
- pbmi->bmiColors[0].rgbRed = 0; /* Empty */
- pbmi->bmiColors[0].rgbGreen = 0;
- pbmi->bmiColors[0].rgbBlue = 0;
- pbmi->bmiColors[0].rgbReserved = 0;
- pbmi->bmiColors[1].rgbRed = pCursor->backRed >> 8; /* Background */
- pbmi->bmiColors[1].rgbGreen = pCursor->backGreen >> 8;
- pbmi->bmiColors[1].rgbBlue = pCursor->backBlue >> 8;
- pbmi->bmiColors[1].rgbReserved = 0;
- pbmi->bmiColors[2].rgbRed = pCursor->foreRed >> 8; /* Foreground */
- pbmi->bmiColors[2].rgbGreen = pCursor->foreGreen >> 8;
- pbmi->bmiColors[2].rgbBlue = pCursor->foreBlue >> 8;
- pbmi->bmiColors[2].rgbReserved = 0;
+
+ pbmiColors[0].rgbRed = 0; /* Empty */
+ pbmiColors[0].rgbGreen = 0;
+ pbmiColors[0].rgbBlue = 0;
+ pbmiColors[0].rgbReserved = 0;
+ pbmiColors[1].rgbRed = pCursor->backRed >> 8; /* Background */
+ pbmiColors[1].rgbGreen = pCursor->backGreen >> 8;
+ pbmiColors[1].rgbBlue = pCursor->backBlue >> 8;
+ pbmiColors[1].rgbReserved = 0;
+ pbmiColors[2].rgbRed = pCursor->foreRed >> 8; /* Foreground */
+ pbmiColors[2].rgbGreen = pCursor->foreGreen >> 8;
+ pbmiColors[2].rgbBlue = pCursor->foreBlue >> 8;
+ pbmiColors[2].rgbReserved = 0;
lpBits =
(unsigned long *) calloc(pScreenPriv->cursor.sm_cx *