Fix crash in the X11 HAL when setting a NULL palette to a surface.
authorLionel Ulmer <lionel.ulmer@free.fr>
Tue, 26 Feb 2002 00:36:21 +0000 (00:36 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 26 Feb 2002 00:36:21 +0000 (00:36 +0000)
dlls/ddraw/dsurface/hal.c
dlls/x11drv/x11ddraw.c

index ca6d364..9948a84 100644 (file)
@@ -223,7 +223,7 @@ void HAL_DirectDrawSurface_set_palette(IDirectDrawSurfaceImpl* This,
     DIB_DirectDrawSurface_set_palette(This, pal);
     data.lpDD = dd_gbl;
     data.lpDDSurface = &This->local;
-    data.lpDDPalette = &pal->global;
+    data.lpDDPalette = (pal != NULL ? &pal->global : NULL);
     data.ddRVal = 0;
     data.Attach = TRUE; /* what's this? */
     data.SetPalette = dd_gbl->lpDDCBtmp->HALDDSurface.SetPalette;
index 5175f16..901485b 100644 (file)
@@ -159,12 +159,14 @@ static DWORD PASCAL X11DRV_DDHAL_DestroySurface(LPDDHAL_DESTROYSURFACEDATA data)
 
 static DWORD PASCAL X11DRV_DDHAL_SetPalette(LPDDHAL_SETPALETTEDATA data)
 {
-  Colormap pal = data->lpDDPalette->u1.dwReserved1;
-  if (pal) {
+  if (data->lpDDPalette && data->lpDDPalette->u1.dwReserved1) {
     if (data->lpDDSurface == X11DRV_DD_Primary) {
       FIXME("stub\n");
       /* we should probably find the ddraw window (maybe data->lpDD->lpExclusiveOwner->hWnd),
-       * and attach the palette to it */
+       * and attach the palette to it
+       *
+       * Colormap pal = data->lpDDPalette->u1.dwReserved1;
+       */
     }
   }
   data->ddRVal = DD_OK;