diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 8512667bc50..08084e41ad7 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -342,13 +342,16 @@ HRESULT WINAPI StorageBaseImpl_OpenStream( } /* - * Check that we're compatible with the parent's storage mode + * Check that we're compatible with the parent's storage mode, but + * only if we are not in transacted mode */ parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags ); - if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) - { - res = STG_E_ACCESSDENIED; - goto end; + if(!(This->ancestorStorage->base.openFlags & STGM_TRANSACTED)) { + if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) + { + res = STG_E_ACCESSDENIED; + goto end; + } } /* @@ -472,13 +475,16 @@ HRESULT WINAPI StorageBaseImpl_OpenStorage( } /* - * Check that we're compatible with the parent's storage mode + * Check that we're compatible with the parent's storage mode, + * but only if we are not transacted */ parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags ); - if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) - { - res = STG_E_ACCESSDENIED; - goto end; + if(!(This->ancestorStorage->base.openFlags & STGM_TRANSACTED)) { + if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) + { + res = STG_E_ACCESSDENIED; + goto end; + } } /* @@ -869,10 +875,13 @@ HRESULT WINAPI StorageBaseImpl_CreateStream( /* * Check that we're compatible with the parent's storage mode + * if not in transacted mode */ parent_grfMode = STGM_ACCESS_MODE( This->ancestorStorage->base.openFlags ); - if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) - return STG_E_ACCESSDENIED; + if(!(parent_grfMode & STGM_TRANSACTED)) { + if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( parent_grfMode ) ) + return STG_E_ACCESSDENIED; + } /* * Initialize the out parameter diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 07aaf11cc49..b4edf136cd8 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -608,6 +608,21 @@ static void test_storage_refcount(void) r = IStream_Release(stm); ok (r == 0, "stream not released\n"); + /* test for grfMode open issue */ + + r = StgOpenStorage( filename, NULL, 0x00010020, NULL, 0, &stg); + ok(r==S_OK, "StgOpenStorage failed\n"); + if(stg) + { + r = IStorage_OpenStream( stg, stmname, 0, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &stm ); + ok(r == S_OK, "OpenStream should succeed\n"); + + todo_wine { + r = IStorage_Release(stg); + ok(r == 0, "wrong ref count\n"); + } + } + DeleteFileW(filename); }