diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 5b4314ffbf1..623516ef5f4 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -5680,6 +5680,10 @@ HRESULT WINAPI StgCreateDocfile( if (reserved != 0) return STG_E_INVALIDPARAMETER; + /* if no share mode given then DENY_NONE is the default */ + if (STGM_SHARE_MODE(grfMode) == 0) + grfMode |= STGM_SHARE_DENY_NONE; + /* * Validate the STGM flags */ @@ -5696,14 +5700,6 @@ HRESULT WINAPI StgCreateDocfile( goto end; } - /* if no share mode given then DENY_NONE is the default */ - if (STGM_SHARE_MODE(grfMode) == 0) - grfMode |= STGM_SHARE_DENY_NONE; - - /* must have at least one access mode */ - if (STGM_ACCESS_MODE(grfMode) == 0) - goto end; - /* in direct mode, can only use SHARE_EXCLUSIVE */ if (!(grfMode & STGM_TRANSACTED) && (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE)) goto end; diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index d96a7ed401b..e6c3542453e 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -163,6 +163,12 @@ static void test_create_storage_modes(void) ok(r == 0, "storage not released\n"); ok(DeleteFileW(filename), "failed to delete file\n"); + r = StgCreateDocfile( filename, STGM_CREATE | STGM_READWRITE |STGM_TRANSACTED, 0, &stg); + ok(r==S_OK, "StgCreateDocfile failed\n"); + r = IStorage_Release(stg); + ok(r == 0, "storage not released\n"); + ok(DeleteFileW(filename), "failed to delete file\n"); + /* test the way excel uses StgCreateDocFile */ r = StgCreateDocfile( filename, STGM_TRANSACTED|STGM_CREATE|STGM_SHARE_DENY_WRITE|STGM_READWRITE, 0, &stg); ok(r==S_OK, "StgCreateDocfile the excel way failed\n");