mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 11:43:31 +00:00
ole32: The stream returned by StgStreamImpl_Clone should have one reference, so call AddRef before returning.
Move the call to StorageBaseImpl_AddStream to StgStreamImpl_Construct to fix StgStreamImpl_Clone, which forgets to call it. Add tests for OLE structured storage tests for IStream::Clone.
This commit is contained in:
parent
85aefa3567
commit
3bd31cfd16
4 changed files with 13 additions and 14 deletions
|
@ -880,6 +880,8 @@ static HRESULT WINAPI StgStreamImpl_Clone(
|
|||
return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */
|
||||
|
||||
*ppstm = (IStream*) new_stream;
|
||||
IStream_AddRef(*ppstm);
|
||||
|
||||
seek_pos.QuadPart = This->currentPosition.QuadPart;
|
||||
|
||||
hres=StgStreamImpl_Seek (*ppstm, seek_pos, STREAM_SEEK_SET, NULL);
|
||||
|
@ -974,6 +976,9 @@ StgStreamImpl* StgStreamImpl_Construct(
|
|||
* this stream are large or small.
|
||||
*/
|
||||
StgStreamImpl_OpenBlockChain(newStream);
|
||||
|
||||
/* add us to the storage's list of active streams */
|
||||
StorageBaseImpl_AddStream(parentStorage, newStream);
|
||||
}
|
||||
|
||||
return newStream;
|
||||
|
|
|
@ -93,8 +93,6 @@ static void StorageImpl_SetNextBlockInChain(StorageImpl* This, ULONG blockIndex,
|
|||
static HRESULT StorageImpl_LoadFileHeader(StorageImpl* This);
|
||||
static void StorageImpl_SaveFileHeader(StorageImpl* This);
|
||||
|
||||
static void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm);
|
||||
|
||||
static void Storage32Impl_AddBlockDepot(StorageImpl* This, ULONG blockIndex);
|
||||
static ULONG Storage32Impl_AddExtBlockDepot(StorageImpl* This);
|
||||
static ULONG Storage32Impl_GetNextExtendedBlock(StorageImpl* This, ULONG blockIndex);
|
||||
|
@ -468,12 +466,6 @@ static HRESULT WINAPI StorageBaseImpl_OpenStream(
|
|||
*/
|
||||
IStream_AddRef(*ppstm);
|
||||
|
||||
/*
|
||||
* add us to the storage's list of active streams
|
||||
*/
|
||||
|
||||
StorageBaseImpl_AddStream(This,newStream);
|
||||
|
||||
res = S_OK;
|
||||
goto end;
|
||||
}
|
||||
|
@ -1063,11 +1055,6 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream(
|
|||
* the reference.
|
||||
*/
|
||||
IStream_AddRef(*ppstm);
|
||||
|
||||
/* add us to the storage's list of active streams
|
||||
*/
|
||||
StorageBaseImpl_AddStream(This,newStream);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1895,7 +1882,7 @@ static HRESULT WINAPI StorageImpl_Stat( IStorage* iface,
|
|||
* Internal stream list handlers
|
||||
*/
|
||||
|
||||
static void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm)
|
||||
void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm)
|
||||
{
|
||||
TRACE("Stream added (stg=%p strm=%p)\n", stg, strm);
|
||||
list_add_tail(&stg->strmHead,&strm->StrmListEntry);
|
||||
|
|
|
@ -257,6 +257,7 @@ struct StorageBaseImpl
|
|||
* StorageBaseImpl stream list handlers
|
||||
*/
|
||||
|
||||
void StorageBaseImpl_AddStream(StorageBaseImpl * stg, StgStreamImpl * strm);
|
||||
void StorageBaseImpl_RemoveStream(StorageBaseImpl * stg, StgStreamImpl * strm);
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -232,6 +232,7 @@ static void test_storage_stream(void)
|
|||
IStorage *stg = NULL;
|
||||
HRESULT r;
|
||||
IStream *stm = NULL;
|
||||
IStream *stm2 = NULL;
|
||||
ULONG count = 0;
|
||||
LARGE_INTEGER pos;
|
||||
ULARGE_INTEGER p;
|
||||
|
@ -281,6 +282,9 @@ static void test_storage_stream(void)
|
|||
r = IStorage_CreateStream(stg, stmname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm );
|
||||
ok(r==S_OK, "IStorage->CreateStream failed\n");
|
||||
|
||||
r = IStream_Clone(stm, &stm2);
|
||||
ok(r==S_OK, "failed to clone stream\n");
|
||||
|
||||
r = IStream_Write(stm, NULL, 0, NULL );
|
||||
ok(r==STG_E_INVALIDPOINTER, "IStream->Write wrong error\n");
|
||||
r = IStream_Write(stm, "Hello\n", 0, NULL );
|
||||
|
@ -317,6 +321,8 @@ static void test_storage_stream(void)
|
|||
ok(count == 0, "read bytes from empty stream\n");
|
||||
|
||||
/* wrap up */
|
||||
r = IStream_Release(stm2);
|
||||
ok(r == 0, "wrong ref count\n");
|
||||
r = IStream_Release(stm);
|
||||
ok(r == 0, "wrong ref count\n");
|
||||
r = IStorage_Release(stg);
|
||||
|
|
Loading…
Reference in a new issue