[4/10] DDraw: SetClipper refcounting fix

Stefan Dösinger stefan at codeweavers.com
Fri Feb 16 12:08:21 CST 2007


-------------- next part --------------
From 0c780c1cbb727742e9a2672867824e718120e0d7 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Tue, 13 Feb 2007 02:21:46 +0100
Subject: [PATCH] DDraw: SetClipper refcounting fix

Its a good idea to addref the new interface before releasing the old one in case that they are the same I
guess :-)
---
 dlls/ddraw/surface.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index a84b08f..cd35832 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -1882,17 +1882,18 @@ IDirectDrawSurfaceImpl_SetClipper(IDirectDrawSurface7 *iface,
                                   IDirectDrawClipper *Clipper)
 {
     ICOM_THIS_FROM(IDirectDrawSurfaceImpl, IDirectDrawSurface7, iface);
+    IDirectDrawClipperImpl *oldClipper = This->clipper;
 
     TRACE("(%p)->(%p)\n",This,Clipper);
     if (ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper) == This->clipper)
         return DD_OK;
 
-    if (This->clipper != NULL)
-        IDirectDrawClipper_Release(ICOM_INTERFACE(This->clipper, IDirectDrawClipper) );
-
     This->clipper = ICOM_OBJECT(IDirectDrawClipperImpl, IDirectDrawClipper, Clipper);
+
     if (Clipper != NULL)
         IDirectDrawClipper_AddRef(Clipper);
+    if(oldClipper)
+        IDirectDrawClipper_Release(ICOM_INTERFACE(oldClipper, IDirectDrawClipper));
 
     return DD_OK;
 }
-- 
1.4.4.3



More information about the wine-patches mailing list