Markus Stockhausen : ole32/storage32: Fix for reference counters in nested storage.

Alexandre Julliard julliard at winehq.org
Mon Sep 28 11:54:34 CDT 2009


Module: wine
Branch: master
Commit: abdebcdbbe61cfaf7c9198f279637ec69daa63d1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=abdebcdbbe61cfaf7c9198f279637ec69daa63d1

Author: Markus Stockhausen <markus.stockhausen at collogia.de>
Date:   Fri Sep 25 16:27:49 2009 +0200

ole32/storage32: Fix for reference counters in nested storage.

---

 dlls/ole32/storage32.c       |    4 +---
 dlls/ole32/tests/storage32.c |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 6e3e1e1..9082334 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -3713,7 +3713,6 @@ static void StorageInternalImpl_Destroy( StorageBaseImpl *iface)
 {
   StorageInternalImpl* This = (StorageInternalImpl*) iface;
 
-  StorageBaseImpl_Release((IStorage*)This->base.ancestorStorage);
   HeapFree(GetProcessHeap(), 0, This);
 }
 
@@ -4312,10 +4311,9 @@ static StorageInternalImpl* StorageInternalImpl_Construct(
     newStorage->base.openFlags = (openFlags & ~STGM_CREATE);
 
     /*
-     * Keep the ancestor storage pointer and nail a reference to it.
+     * Keep the ancestor storage pointer but do not nail a reference to it.
      */
     newStorage->base.ancestorStorage = ancestorStorage;
-    StorageBaseImpl_AddRef((IStorage*)(newStorage->base.ancestorStorage));
 
     /*
      * Keep the index of the root property set for this storage,
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index fec854e..620e6cb 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1470,6 +1470,45 @@ static void test_fmtusertypestg(void)
     }
 }
 
+static void test_references(void)
+{
+    IStorage *stg,*stg2;
+    HRESULT hr;
+    unsigned c1,c2;
+    static const WCHAR StorName[] = { 'D','a','t','a','S','p','a','c','e','I','n','f','o',0 };
+
+    DeleteFileA(filenameA);
+
+    hr = StgCreateDocfile( filename, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
+    ok(hr==S_OK, "StgCreateDocfile failed\n");
+
+    if (SUCCEEDED(hr))
+    {
+        IStorage_Release(stg);
+
+        hr = StgOpenStorage( filename, NULL, STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, NULL, 0, &stg);
+        ok(hr==S_OK, "StgOpenStorage failed (result=%x)\n",hr);
+
+        if (SUCCEEDED(hr))
+        {
+            hr = IStorage_CreateStorage(stg,StorName,STGM_READWRITE | STGM_SHARE_EXCLUSIVE,0,0,&stg2);
+            ok(hr == S_OK, "IStorage_CreateStorage failed (result=%x)\n",hr);
+
+            if (SUCCEEDED(hr))
+            {
+                c1 = IStorage_AddRef(stg);
+                ok(c1 == 2, "creating internal storage added references to ancestor\n");
+                c1 = IStorage_AddRef(stg);
+                IStorage_Release(stg2);
+                c2 = IStorage_AddRef(stg) - 1;
+                ok(c1 == c2, "releasing internal storage removed references to ancestor\n");
+            }
+            c1 = IStorage_Release(stg);
+            while ( c1 ) c1 = IStorage_Release(stg);
+        }
+    }
+}
+
 START_TEST(storage32)
 {
     CHAR temp[MAX_PATH];
@@ -1497,4 +1536,5 @@ START_TEST(storage32)
     test_readonly();
     test_simple();
     test_fmtusertypestg();
+    test_references();
 }




More information about the wine-cvs mailing list