Module: wine Branch: refs/heads/master Commit: eaec7793d56a31df2cc8270ed0f4e26ae976ef76 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=eaec7793d56a31df2cc8270e...
Author: Stefan Dösinger stefandoesinger@gmx.at Date: Sun May 14 18:01:31 2006 +0200
wined3d: Avoid a NULL dereference in RealizePalette.
---
dlls/wined3d/surface.c | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 22b3f0e..04c3ec3 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1773,14 +1773,24 @@ HRESULT WINAPI IWineD3DSurfaceImpl_Reali This->Flags |= SFLAG_DIRTY; }
- TRACE("(%p): Updating the palette\n", This); - for (n=0; n<256; n++) { - col[n].rgbRed = pal->palents[n].peRed; - col[n].rgbGreen = pal->palents[n].peGreen; - col[n].rgbBlue = pal->palents[n].peBlue; - col[n].rgbReserved = 0; + if(This->Flags & SFLAG_DIBSECTION) { + TRACE("(%p): Updating the hdc's palette\n", This); + for (n=0; n<256; n++) { + if(pal) { + col[n].rgbRed = pal->palents[n].peRed; + col[n].rgbGreen = pal->palents[n].peGreen; + col[n].rgbBlue = pal->palents[n].peBlue; + } else { + IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + /* Use the default device palette */ + col[n].rgbRed = device->palettes[device->currentPalette][n].peRed; + col[n].rgbGreen = device->palettes[device->currentPalette][n].peGreen; + col[n].rgbBlue = device->palettes[device->currentPalette][n].peBlue; + } + col[n].rgbReserved = 0; + } + SetDIBColorTable(This->hDC, 0, 256, col); } - SetDIBColorTable(This->hDC, 0, 256, col);
return WINED3D_OK; }