ole32: Fix crash when calling CreateStorage on read only storage.

This commit is contained in:
Vincent Povirk 2009-05-29 16:40:15 -05:00 committed by Alexandre Julliard
parent 4a0901fb87
commit 93a155381f
2 changed files with 2 additions and 3 deletions

View File

@ -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
{

View File

@ -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 );