From: Alex Henrie Subject: [PATCH] winex11: Copy icon color table in 256-color mode (Valgrind) Message-Id: <20191016010059.4932-1-alexhenrie24@gmail.com> Date: Tue, 15 Oct 2019 19:00:59 -0600 create_icon_pixmaps calls GetDIBits and create_pixmap_from_image, which calls get_dib_info_size. GetDIBits sets biClrUsed to 0, which is a special value meaning that the size of the color table is the maximum size possible given the bit depth. Without code to handle that case in get_dib_info_size, the color table is lost. gdi32's version of get_dib_info_size does not have to deal with biClrUsed being zero because bitmapinfo_from_user_bitmapinfo makes a copy of the bitmap info with biClrUsed set to a nonzero value. However, there is no reason to have anything that complicated in winex11. Signed-off-by: Alex Henrie --- Supersedes patch 171325 --- dlls/winex11.drv/bitblt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 4eec3288e2..973af40c33 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -924,13 +924,14 @@ static void free_ximage_bits( struct gdi_image_bits *bits ) XFree( bits->ptr ); } -/* only for use on sanitized BITMAPINFO structures */ static inline int get_dib_info_size( const BITMAPINFO *info, UINT coloruse ) { if (info->bmiHeader.biCompression == BI_BITFIELDS) return sizeof(BITMAPINFOHEADER) + 3 * sizeof(DWORD); if (coloruse == DIB_PAL_COLORS) return sizeof(BITMAPINFOHEADER) + info->bmiHeader.biClrUsed * sizeof(WORD); + if (!info->bmiHeader.biClrUsed && info->bmiHeader.biBitCount <= 8) + return FIELD_OFFSET( BITMAPINFO, bmiColors[1 << info->bmiHeader.biBitCount] ); return FIELD_OFFSET( BITMAPINFO, bmiColors[info->bmiHeader.biClrUsed] ); } -- 2.23.0