From 19201c403e7aa15bb1095ee5cad4383e21917865 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 29 May 2009 16:40:15 -0500 Subject: [PATCH] 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..af1e3b1 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 ); -- 1.5.4.3