Vincent Povirk : ole32: Forbid opening the same storage twice.
Alexandre Julliard
julliard at winehq.org
Fri Nov 20 10:48:00 CST 2009
Module: wine
Branch: master
Commit: c62a4ad8413937c0dc7589276c1e920de5d50dd4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c62a4ad8413937c0dc7589276c1e920de5d50dd4
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Thu Nov 19 13:55:34 2009 -0600
ole32: Forbid opening the same storage twice.
---
dlls/ole32/storage32.c | 23 +++++++++++++++++++++++
dlls/ole32/tests/storage32.c | 4 ++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 269f611..773855f 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -113,6 +113,7 @@ static BOOL StorageImpl_ReadDWordFromBigBlock( StorageImpl* This,
ULONG blockIndex, ULONG offset, DWORD* value);
static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEntry);
+static BOOL StorageBaseImpl_IsStorageOpen(StorageBaseImpl * stg, DirRef storageEntry);
static void StorageInternalImpl_Invalidate( StorageInternalImpl *This );
/* OLESTREAM memory structure to use for Get and Put Routines */
@@ -579,6 +580,13 @@ static HRESULT WINAPI StorageBaseImpl_OpenStorage(
if ( (storageEntryRef!=DIRENTRY_NULL) &&
(currentEntry.stgType==STGTY_STORAGE) )
{
+ if (StorageBaseImpl_IsStorageOpen(This, storageEntryRef))
+ {
+ /* A single storage cannot be opened a second time. */
+ res = STG_E_ACCESSDENIED;
+ goto end;
+ }
+
newStorage = StorageInternalImpl_Construct(
This->ancestorStorage,
grfMode,
@@ -1875,6 +1883,21 @@ static BOOL StorageBaseImpl_IsStreamOpen(StorageBaseImpl * stg, DirRef streamEnt
return FALSE;
}
+static BOOL StorageBaseImpl_IsStorageOpen(StorageBaseImpl * stg, DirRef storageEntry)
+{
+ StorageInternalImpl *childstg;
+
+ LIST_FOR_EACH_ENTRY(childstg, &stg->storageHead, StorageInternalImpl, ParentListEntry)
+ {
+ if (childstg->base.storageDirEntry == storageEntry)
+ {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
static void StorageBaseImpl_DeleteAll(StorageBaseImpl * stg)
{
struct list *cur, *cur2;
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index d11f179..42741ac 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1060,13 +1060,13 @@ static void test_substorage_share(void)
if (r == S_OK)
{
r = IStorage_OpenStorage(stg, stgname, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3);
- todo_wine ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
+ ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
if (r == S_OK)
IStorage_Release(stg3);
r = IStorage_OpenStorage(stg, stgname, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3);
- todo_wine ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
+ ok(r==STG_E_ACCESSDENIED, "IStorage->OpenStorage should fail %08x\n", r);
if (r == S_OK)
IStorage_Release(stg3);
More information about the wine-cvs
mailing list