riched20: Avoid releasing a non-existent interface. (try 2)

Jactry Zeng jactry92 at gmail.com
Wed Apr 16 22:15:00 CDT 2014


ChangeLog:
- Corrected code style
-------------- next part --------------
From 7a9121e80e4a7b8fc36dc0e8eb3dfa493ac82039 Mon Sep 17 00:00:00 2001
From: Jactry Zeng <jactry92 at gmail.com>
Date: Thu, 17 Apr 2014 11:02:02 +0800
Subject: riched20: Avoid releasing a non-existent interface.

---
 dlls/riched20/richole.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 6f2d579..e10c124 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -129,9 +129,16 @@ IRichEditOle_fnRelease(IRichEditOle *me)
     if (!ref)
     {
         TRACE ("Destroying %p\n", This);
-        This->txtSel->reOle = NULL;
-        ITextSelection_Release(&This->txtSel->ITextSelection_iface);
-        IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
+        if (This->txtSel)
+        {
+            This->txtSel->reOle = NULL;
+            ITextSelection_Release(&This->txtSel->ITextSelection_iface);
+        }
+        if (This->clientSite)
+        {
+            This->clientSite->reOle = NULL;
+            IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
+        }
         heap_free(This);
     }
     return ref;
@@ -197,7 +204,11 @@ static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
     IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
     if (ref == 0)
+    {
+        if (This->reOle)
+            This->reOle->clientSite = NULL;
         heap_free(This);
+    }
     return ref;
 }
 
@@ -728,7 +739,11 @@ static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
     ITextSelectionImpl *This = impl_from_ITextSelection(me);
     ULONG ref = InterlockedDecrement(&This->ref);
     if (ref == 0)
+    {
+        if (This->reOle)
+            This->reOle->txtSel = NULL;
         heap_free(This);
+    }
     return ref;
 }
 
-- 
1.8.5.2 (Apple Git-48)



More information about the wine-patches mailing list