ole32: Add a check for hglobal pointer to GetHGlobalFromStream.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2020-08-12 08:19:55 +08:00 committed by Alexandre Julliard
parent 019fcaa364
commit d5c5387622
2 changed files with 8 additions and 2 deletions

View File

@ -664,10 +664,10 @@ HRESULT WINAPI GetHGlobalFromStream(IStream* pstm, HGLOBAL* phglobal)
{
HGLOBALStreamImpl* pStream;
if (pstm == NULL)
if (!pstm || !phglobal)
return E_INVALIDARG;
pStream = (HGLOBALStreamImpl*) pstm;
pStream = impl_from_IStream(pstm);
/*
* Verify that the stream object was created with CreateStreamOnHGlobal.

View File

@ -561,6 +561,12 @@ static void test_IStream_Clone(void)
hr = CreateStreamOnHGlobal(orig_hmem, TRUE, &stream);
ok(hr == S_OK, "unexpected %#x\n", hr);
hr = GetHGlobalFromStream(stream, NULL);
ok(hr == E_INVALIDARG, "unexpected %#x\n", hr);
hr = GetHGlobalFromStream(NULL, &hmem);
ok(hr == E_INVALIDARG, "unexpected %#x\n", hr);
stream_info(stream, &hmem, &size, &pos);
ok(hmem == orig_hmem, "handles should match\n");
ok(size == 0, "unexpected %d\n", size);