Module: wine Branch: master Commit: 6408679e44f4d8f58e8efff9cafe89c67c9ddc12 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6408679e44f4d8f58e8efff9ca...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Dec 22 04:10:37 2010 +0300
oleaut32: Fix GetLibAttr for null argument, plus error handling.
---
dlls/oleaut32/tests/typelib.c | 6 ++++++ dlls/oleaut32/typelib.c | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 7aa032e..495561a 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -518,6 +518,9 @@ static void test_TypeInfo(void) hr = ITypeLib_GetTypeInfo(pTypeLib, 0, NULL); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+ hr = ITypeLib_GetLibAttr(pTypeLib, NULL); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + hr = ITypeLib_GetTypeInfoType(pTypeLib, count, &kind); ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
@@ -1362,6 +1365,9 @@ static void test_CreateTypeLib(void) { hres = ITypeLib_GetTypeInfoType(tl, 0, NULL); ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
+ hres = ITypeLib_GetLibAttr(tl, NULL); + ok(hres == E_INVALIDARG, "got %08x\n", hres); + hres = ITypeLib_GetLibAttr(tl, &libattr); ok(hres == S_OK, "got %08x\n", hres);
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 8eda482..0ea185c 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -4351,12 +4351,18 @@ static HRESULT WINAPI ITypeLib2_fnGetTypeInfoOfGuid( */ static HRESULT WINAPI ITypeLib2_fnGetLibAttr( ITypeLib2 *iface, - LPTLIBATTR *ppTLibAttr) + LPTLIBATTR *attr) { ITypeLibImpl *This = (ITypeLibImpl *)iface; - TRACE("(%p)\n",This); - *ppTLibAttr = HeapAlloc(GetProcessHeap(), 0, sizeof(**ppTLibAttr)); - **ppTLibAttr = This->LibAttr; + + TRACE("(%p, %p)\n", This, attr); + + if (!attr) return E_INVALIDARG; + + *attr = HeapAlloc(GetProcessHeap(), 0, sizeof(**attr)); + if (!*attr) return E_OUTOFMEMORY; + + **attr = This->LibAttr; return S_OK; }