mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
ole32: ReadClassStm should return STG_E_READFAULT is not all of the data could be read, not S_FALSE.
Clear pclsid in case of errors. Add tests for ReadClassStm.
This commit is contained in:
parent
de527d5ec0
commit
b1ee49a74d
@ -7930,13 +7930,16 @@ HRESULT WINAPI ReadClassStm(IStream *pStm,CLSID *pclsid)
|
||||
if (!pStm || !pclsid)
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* clear the output args */
|
||||
memcpy(pclsid, &CLSID_NULL, sizeof(*pclsid));
|
||||
|
||||
res = IStream_Read(pStm,(void*)pclsid,sizeof(CLSID),&nbByte);
|
||||
|
||||
if (FAILED(res))
|
||||
return res;
|
||||
|
||||
if (nbByte != sizeof(CLSID))
|
||||
return S_FALSE;
|
||||
return STG_E_READFAULT;
|
||||
else
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
DEFINE_GUID( test_stg_cls, 0x88888888, 0x0425, 0x0000, 0,0,0,0,0,0,0,0);
|
||||
|
||||
#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
|
||||
|
||||
static void test_hglobal_storage_stat(void)
|
||||
{
|
||||
ILockBytes *ilb = NULL;
|
||||
@ -913,6 +915,36 @@ static void test_transact(void)
|
||||
ok( r == TRUE, "deleted file\n");
|
||||
}
|
||||
|
||||
static void test_ReadClassStm(void)
|
||||
{
|
||||
CLSID clsid;
|
||||
HRESULT hr;
|
||||
IStream *pStream;
|
||||
static const LARGE_INTEGER llZero;
|
||||
|
||||
hr = ReadClassStm(NULL, &clsid);
|
||||
ok(hr == E_INVALIDARG, "ReadClassStm should have returned E_INVALIDARG instead of 0x%08x\n", hr);
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
||||
ok_ole_success(hr, "CreateStreamOnHGlobal");
|
||||
hr = WriteClassStm(pStream, &test_stg_cls);
|
||||
ok_ole_success(hr, "WriteClassStm");
|
||||
|
||||
hr = ReadClassStm(pStream, NULL);
|
||||
ok(hr == E_INVALIDARG, "ReadClassStm should have returned E_INVALIDARG instead of 0x%08x\n", hr);
|
||||
|
||||
/* test not rewound stream */
|
||||
hr = ReadClassStm(pStream, &clsid);
|
||||
ok(hr == STG_E_READFAULT, "ReadClassStm should have returned STG_E_READFAULT instead of 0x%08x\n", hr);
|
||||
ok(IsEqualCLSID(&clsid, &CLSID_NULL), "clsid should have been zeroed\n");
|
||||
|
||||
hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
||||
ok_ole_success(hr, "IStream_Seek");
|
||||
hr = ReadClassStm(pStream, &clsid);
|
||||
ok_ole_success(hr, "ReadClassStm");
|
||||
ok(IsEqualCLSID(&clsid, &test_stg_cls), "clsid should have been set to CLSID_WineTest\n");
|
||||
}
|
||||
|
||||
START_TEST(storage32)
|
||||
{
|
||||
test_hglobal_storage_stat();
|
||||
@ -923,4 +955,5 @@ START_TEST(storage32)
|
||||
test_storage_refcount();
|
||||
test_streamenum();
|
||||
test_transact();
|
||||
test_ReadClassStm();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user