From 6408679e44f4d8f58e8efff9cafe89c67c9ddc12 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 22 Dec 2010 04:10:37 +0300 Subject: [PATCH] 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 7aa032ed833..495561a46bc 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 8eda482406a..0ea185c2f76 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; }