From 87ac6b8406318383f2a5bc70dde18c1a579f796e Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 12 Jan 2012 20:49:50 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/src/winlayer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 3022822b3..d1f134f50 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -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));