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

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


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

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

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

---

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

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 748eac8..d68f09f 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -979,6 +979,10 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream(
       (grfMode & STGM_TRANSACTED))
     return STG_E_INVALIDFUNCTION;
 
+  /* Can't create a stream on read-only storage */
+  if ( STGM_ACCESS_MODE( This->openFlags ) == STGM_READ )
+    return STG_E_ACCESSDENIED;
+
   /*
    * Check that we're compatible with the parent's storage mode
    * if not in transacted mode
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index 7d4fb30..f932765 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1302,13 +1302,11 @@ void test_readonly(void)
         ok(hr == S_OK, "should succeed, res=%x\n", hr);
         if (SUCCEEDED(hr))
         {
-#if 0 /* crashes on Wine */
             /* CreateStream on read-only storage, name exists */
             hr = IStorage_CreateStream( stg2, streamW, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READ, 0, 0, &stream );
             ok(hr == STG_E_ACCESSDENIED, "should fail, res=%x\n", hr);
             if (SUCCEEDED(hr))
                 IStream_Release(stream);
-#endif
 
             /* CreateStream on read-only storage, name does not exist */
             hr = IStorage_CreateStream( stg2, storageW, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READ, 0, 0, &stream );




More information about the wine-cvs mailing list