From 282bdb3564d7c26396cdfa9cd871c801799812df Mon Sep 17 00:00:00 2001 From: Gerard Patel Date: Sat, 31 Mar 2001 00:51:54 +0000 Subject: [PATCH] Don't try to create file twice in the NULL filename case for StgCreateDocFile. --- dlls/ole32/storage32.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index f4b705739fe..a67dcd66c58 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -5294,6 +5294,11 @@ HRESULT WINAPI StgCreateDocfile( WCHAR tempPath[MAX_PATH]; WCHAR prefix[] = { 'S', 'T', 'O', 0 }; + if (!(grfMode & STGM_SHARE_EXCLUSIVE)) + return STG_E_INVALIDFLAG; + if (!(grfMode & (STGM_WRITE|STGM_READWRITE))) + return STG_E_INVALIDFLAG; + memset(tempPath, 0, sizeof(tempPath)); memset(tempFileName, 0, sizeof(tempFileName)); @@ -5304,6 +5309,12 @@ HRESULT WINAPI StgCreateDocfile( pwcsName = tempFileName; else return STG_E_INSUFFICIENTMEMORY; + + creationMode = TRUNCATE_EXISTING; + } + else + { + creationMode = GetCreationModeFromSTGM(grfMode); } /* @@ -5311,7 +5322,6 @@ HRESULT WINAPI StgCreateDocfile( */ shareMode = GetShareModeFromSTGM(grfMode); accessMode = GetAccessModeFromSTGM(grfMode); - creationMode = GetCreationModeFromSTGM(grfMode); if (grfMode & STGM_DELETEONRELEASE) fileAttributes = FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_DELETE_ON_CLOSE;