Module: wine Branch: master Commit: 2c911147b923e93c19b8c02aff4f15d19d362930 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2c911147b923e93c19b8c02aff...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Feb 17 13:01:33 2010 +0100
oleaut32: Fix crash in LoadTypeLib if typelib name is not specified.
---
dlls/oleaut32/tests/typelib.c | 28 ++++++++++++++++++++++++++++ dlls/oleaut32/typelib.c | 6 +++--- 2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 936c497..843af08 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -968,6 +968,33 @@ if(use_midl_tlb) { return; }
+static void test_CreateTypeLib(void) { + char filename[MAX_PATH]; + WCHAR filenameW[MAX_PATH]; + ICreateTypeLib2 *createtl; + ITypeLib *tl; + HRESULT hres; + + trace("CreateTypeLib tests\n"); + + GetTempFileNameA(".", "tlb", 0, filename); + MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, MAX_PATH); + + hres = CreateTypeLib2(SYS_WIN32, filenameW, &createtl); + ok(hres == S_OK, "got %08x\n", hres); + + hres = ICreateTypeLib2_SaveAllChanges(createtl); + ok(hres == S_OK, "got %08x\n", hres); + ICreateTypeLib2_Release(createtl); + + hres = LoadTypeLib(filenameW, &tl); + ok(hres == S_OK, "got %08x\n", hres); + + ITypeLib_Release(tl); + + DeleteFileA(filename); +} + #if 0 /* use this to generate more tests */
#define OLE_CHECK(x) { HRESULT hr = x; if (FAILED(hr)) { printf(#x "failed - %x\n", hr); return; } } @@ -1480,6 +1507,7 @@ START_TEST(typelib) test_TypeInfo(); test_QueryPathOfRegTypeLib(); test_inheritance(); + test_CreateTypeLib();
if ((filename = create_test_typelib())) { diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index 2ad5412..445eac5 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -552,7 +552,9 @@ HRESULT WINAPI RegisterTypeLib( LPOLESTR doc;
/* Set the human-readable name of the typelib */ - if (SUCCEEDED(ITypeLib_GetDocumentation(ptlib, -1, NULL, &doc, NULL, NULL))) + if (FAILED(ITypeLib_GetDocumentation(ptlib, -1, NULL, &doc, NULL, NULL))) + res = E_FAIL; + else if (doc) { if (RegSetValueExW(key, NULL, 0, REG_SZ, (BYTE *)doc, (lstrlenW(doc)+1) * sizeof(OLECHAR)) != ERROR_SUCCESS) @@ -560,8 +562,6 @@ HRESULT WINAPI RegisterTypeLib(
SysFreeString(doc); } - else - res = E_FAIL;
/* Make up the name of the typelib path subkey */ if (!get_lcid_subkey( attr->lcid, attr->syskind, tmp )) res = E_FAIL;