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>
This commit is contained in:
parent
41d03c9ccc
commit
784c006adb
@ -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 *
|
||||
|
Loading…
Reference in New Issue
Block a user