diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2013-04-07 18:56:21 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2013-04-08 14:20:28 +0100 |
commit | d6125b68145c1a88193217be1ad960ed58c5fcca (patch) | |
tree | e72c3ae95f3ba03d1ddfbfab3606df573fb81754 | |
parent | f678537c00ae7b7db15ad31b1b96385cb4ffb589 (diff) |
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.
-rw-r--r-- | hw/xwin/wmutil/cursor_convert.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/hw/xwin/wmutil/cursor_convert.c b/hw/xwin/wmutil/cursor_convert.c index 118d9e849..727d83813 100644 --- a/hw/xwin/wmutil/cursor_convert.c +++ b/hw/xwin/wmutil/cursor_convert.c @@ -200,9 +200,12 @@ winXCursorToHCURSOR(WMUTIL_CURSOR *pCursor) } if (!lpBits) { + RGBQUAD *pbmiColors; /* Bicolor, use a palettized DIB */ WIN_DEBUG_MSG("winXCursorToHCURSOR: 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 = sm_cx; @@ -213,18 +216,19 @@ winXCursorToHCURSOR(WMUTIL_CURSOR *pCursor) 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(sm_cx * |