Vincent Povirk : ole32: Fix crash when calling CreateStorage on read only storage.

Alexandre Julliard julliard at winehq.org
Mon Jun 1 10:01:01 CDT 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Fri May 29 16:40:15 2009 -0500

ole32: Fix crash when calling CreateStorage on read only storage.

---

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

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index d68f09f..9f3930e 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -1230,7 +1230,8 @@ static HRESULT WINAPI StorageImpl_CreateStorage(
     /*
      * An element with this name already exists
      */
-    if (STGM_CREATE_MODE(grfMode) == STGM_CREATE)
+    if (STGM_CREATE_MODE(grfMode) == STGM_CREATE &&
+        STGM_ACCESS_MODE(This->base.openFlags) != STGM_READ)
       IStorage_DestroyElement(iface, pwcsName);
     else
     {
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index f932765..84c4b0f 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1314,13 +1314,11 @@ void test_readonly(void)
             if (SUCCEEDED(hr))
                 IStream_Release(stream);
 
-#if 0 /* crashes on Wine */
             /* CreateStorage on read-only storage, name exists */
             hr = IStorage_CreateStorage( stg2, streamW, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READ, 0, 0, &stg3 );
             ok(hr == STG_E_FILEALREADYEXISTS, "should fail, res=%x\n", hr);
             if (SUCCEEDED(hr))
                 IStream_Release(stg3);
-#endif
 
             /* CreateStorage on read-only storage, name does not exist */
             hr = IStorage_CreateStorage( stg2, storageW, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READ, 0, 0, &stg3 );




More information about the wine-cvs mailing list