winlayer.c: in WM_PALETTECHANGED handling code ("someone stole the palette

so try and steal it back"), prevent calling IDirectDrawSurface_SetPalette()
with NULL arguments, causing a crash.  It's happened for me on Vista, when
initially changing from 8-bit to 32-bit mode.

git-svn-id: https://svn.eduke32.com/eduke32@2255 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-01-12 20:49:50 +00:00
parent a57b566c0b
commit 87ac6b8406

View file

@ -3706,7 +3706,14 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA
// someone stole the palette so try and steal it back
if (bDDrawInited && bpp == 8 && fullscreen)
{
int32_t result = IDirectDrawSurface_SetPalette(lpDDSPrimary, lpDDPalette);
int32_t result;
// PK: for me, happens on Vista when changing from fullscreen 8-bit to 32-bit
if (!lpDDSPrimary || !lpDDPalette)
break;
result = IDirectDrawSurface_SetPalette(lpDDSPrimary, lpDDPalette);
if (result != DD_OK)
{
initprintf("Palette set failed: %s\n", GetDDrawError(result));