Dmitry Timoshkov : ole32: Add a check for hglobal pointer to GetHGlobalFromStream.
Alexandre Julliard
julliard at winehq.org
Tue Aug 18 16:34:23 CDT 2020
Module: wine
Branch: master
Commit: d5c53876228125a045f699c880394d0e6cc08a72
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d5c53876228125a045f699c880394d0e6cc08a72
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Wed Aug 12 08:19:55 2020 +0800
ole32: Add a check for hglobal pointer to GetHGlobalFromStream.
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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);
More information about the wine-cvs
mailing list