[PATCH] ole32: Add a check for hglobal pointer to GetHGlobalFromStream.
Dmitry Timoshkov
dmitry at baikal.ru
Tue Aug 11 19:19:55 CDT 2020
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
dlls/ole32/hglobalstream.c | 4 ++--
dlls/ole32/tests/hglobalstream.c | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index 4590bb9c43..4cfedd66a1 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -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.
diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c
index 2f386914af..5bcf9abfbd 100644
--- a/dlls/ole32/tests/hglobalstream.c
+++ b/dlls/ole32/tests/hglobalstream.c
@@ -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);
--
2.26.2
More information about the wine-devel
mailing list