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:
Rob Shearman 2007-01-09 17:17:52 +00:00 committed by Alexandre Julliard
parent de527d5ec0
commit b1ee49a74d
2 changed files with 37 additions and 1 deletions

View File

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

View File

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