Commit f3c99197 authored by Glenn Wurster's avatar Glenn Wurster Committed by Alexandre Julliard

Fix array index crash in buidling GDI palette from logical palette.

parent 44cb0906
...@@ -418,18 +418,24 @@ static RGBQUAD *X11DRV_DIB_BuildColorTable( X11DRV_PDEVICE *physDev, WORD coloru ...@@ -418,18 +418,24 @@ static RGBQUAD *X11DRV_DIB_BuildColorTable( X11DRV_PDEVICE *physDev, WORD coloru
else else
{ {
HPALETTE hpal = GetCurrentObject(physDev->hdc, OBJ_PAL); HPALETTE hpal = GetCurrentObject(physDev->hdc, OBJ_PAL);
PALETTEENTRY pal_ents[256]; PALETTEENTRY * pal_ents;
WORD *index = (WORD*) ((LPBYTE) info + (WORD) info->bmiHeader.biSize); WORD *index = (WORD*) ((LPBYTE) info + (WORD) info->bmiHeader.biSize);
int logcolors, entry;
GetPaletteEntries(hpal, 0, 256, pal_ents); logcolors = GetPaletteEntries( hpal, 0, 0, NULL );
pal_ents = HeapAlloc(GetProcessHeap(), 0, logcolors * sizeof(*pal_ents));
logcolors = GetPaletteEntries( hpal, 0, logcolors, pal_ents );
for(i = 0; i < colors; i++, index++) for(i = 0; i < colors; i++, index++)
{ {
colorTable[i].rgbRed = pal_ents[*index].peRed; entry = *index % logcolors;
colorTable[i].rgbGreen = pal_ents[*index].peGreen; colorTable[i].rgbRed = pal_ents[entry].peRed;
colorTable[i].rgbBlue = pal_ents[*index].peBlue; colorTable[i].rgbGreen = pal_ents[entry].peGreen;
colorTable[i].rgbBlue = pal_ents[entry].peBlue;
colorTable[i].rgbReserved = 0; colorTable[i].rgbReserved = 0;
} }
HeapFree(GetProcessHeap(), 0, pal_ents);
} }
return colorTable; return colorTable;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment