Added a check for a null clipper in IDirectDrawSurfaceImpl_SetClipper

Edward Wigg ewigg at
Sun May 20 06:51:08 CDT 2007

I tried to run Age of Empires 2 but it crashed just before the game started (single player -> random map -> press the "start game" button). It turns out AOE2 sets a null clipper. This fix checks for the null pointer when calling 
IWineD3DSurface_SetClipper. Passing NULL does not break any assumptions because 
IWineD3DSurface_GetClipper specifically checks for NULL as an indication that no clipper is attached.
AOE2 now works for me.

 dlls/ddraw/surface.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 62edb21..0a113f8 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -1981,7 +1981,8 @@ IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
         IDirectDrawClipper_Release(ICOM_INTERFACE(oldClipper, IDirectDrawClipper));
-    return IWineD3DSurface_SetClipper(This->WineD3DSurface, This->clipper->wineD3DClipper);
+    return IWineD3DSurface_SetClipper(This->WineD3DSurface, 
+        This->clipper ? This->clipper->wineD3DClipper : NULL);

More information about the wine-patches mailing list