Fix GDI_PAL_COLORS crash.
Glenn Wurster
gwurster at scs.carleton.ca
Mon Apr 4 13:24:20 CDT 2005
GDI_PAL_COLORS is composed of 16 bit indexes, we only got the first
256 colours. Instead of making a copy of possibly 65535 different
palette entries in the logical palette, get a pointer and build up the
dib colours as needed. Yes, the % is how windows works. Yes,
conformance tests are in the queue of patches to be submitted.
Author:
* Glenn Wurster (gwurster at scs.carleton.ca)
ChangeLog:
* Fix array index crash in buidling GDI palette from Logical Palette.
Index: dlls/x11drv/dib.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/dib.c,v
retrieving revision 1.27
diff -u -r1.27 dib.c
--- dlls/x11drv/dib.c 31 Mar 2005 19:13:03 -0000 1.27
+++ dlls/x11drv/dib.c 1 Apr 2005 05:55:17 -0000
@@ -418,18 +418,21 @@
else
{
HPALETTE hpal = GetCurrentObject(physDev->hdc, OBJ_PAL);
- PALETTEENTRY pal_ents[256];
+ PALETTEOBJ * palPtr = GDI_GetObjPtr( hpal, PALETTE_MAGIC );
WORD *index = (WORD*) ((LPBYTE) info + (WORD) info->bmiHeader.biSize);
+ int entry;
- GetPaletteEntries(hpal, 0, 256, pal_ents);
+ if( !palPtr ) return 0;
for(i = 0; i < colors; i++, index++)
{
- colorTable[i].rgbRed = pal_ents[*index].peRed;
- colorTable[i].rgbGreen = pal_ents[*index].peGreen;
- colorTable[i].rgbBlue = pal_ents[*index].peBlue;
+ entry = *index % palPtr->logpalette.palNumEntries;
+ colorTable[i].rgbRed = palPtr->logpalette.palPalEntry[entry].peRed;
+ colorTable[i].rgbGreen = palPtr->logpalette.palPalEntry[entry].peGreen;
+ colorTable[i].rgbBlue = palPtr->logpalette.palPalEntry[entry].peBlue;
colorTable[i].rgbReserved = 0;
}
+ GDI_ReleaseObj( hpal );
}
return colorTable;
}
More information about the wine-patches
mailing list