[PATCH 3/4] Fix GetLibAttr for null argument, plus error handling

Nikolay Sivov nsivov at codeweavers.com
Tue Dec 21 19:10:37 CST 2010


---
 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;
 }
 
-- 
1.5.6.5



--------------050505090603050104020702--



More information about the wine-patches mailing list