oleaut32: LoadRegTypeLib() should check actual typelib version.

This commit is contained in:
Nikolay Sivov 2013-09-24 12:27:02 +04:00 committed by Alexandre Julliard
parent 4be3013014
commit 1c23b501f7
2 changed files with 39 additions and 2 deletions

View file

@ -4734,7 +4734,6 @@ static void test_LoadRegTypeLib(void)
if (hr == S_OK) ITypeLib_Release(tl);
hr = LoadRegTypeLib(&LIBID_register_test, 2, 0, LOCALE_NEUTRAL, &tl);
todo_wine
ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
/* manifest version is 2.7, actual is 2.5 */
@ -4755,7 +4754,6 @@ todo_wine
if (hr == S_OK) ITypeLib_Release(tl);
hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 7, LOCALE_NEUTRAL, &tl);
todo_wine
ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 5, LOCALE_NEUTRAL, &tl);
@ -5025,6 +5023,30 @@ static void test_SetTypeDescAlias(SYSKIND kind)
DeleteFileA(filenameA);
}
static void test_GetLibAttr(void)
{
ULONG ref1, ref2;
TLIBATTR *attr;
ITypeLib *tl;
HRESULT hr;
hr = LoadTypeLib(wszStdOle2, &tl);
ok(hr == S_OK, "got 0x%08x\n", hr);
ref1 = ITypeLib_AddRef(tl);
ITypeLib_Release(tl);
hr = ITypeLib_GetLibAttr(tl, &attr);
ok(hr == S_OK, "got 0x%08x\n", hr);
ref2 = ITypeLib_AddRef(tl);
ITypeLib_Release(tl);
ok(ref2 == ref1, "got %d, %d\n", ref2, ref1);
ITypeLib_ReleaseTLibAttr(tl, attr);
ITypeLib_Release(tl);
}
START_TEST(typelib)
{
const char *filename;
@ -5062,4 +5084,5 @@ START_TEST(typelib)
test_LoadTypeLib();
test_TypeInfo2_GetContainingTypeLib();
test_LoadRegTypeLib();
test_GetLibAttr();
}

View file

@ -536,6 +536,20 @@ HRESULT WINAPI LoadRegTypeLib(
{
res= LoadTypeLib(bstr, ppTLib);
SysFreeString(bstr);
if (*ppTLib)
{
TLIBATTR *attr;
res = ITypeLib_GetLibAttr(*ppTLib, &attr);
if (res == S_OK && (attr->wMajorVerNum != wVerMajor || attr->wMinorVerNum < wVerMinor))
{
ITypeLib_ReleaseTLibAttr(*ppTLib, attr);
ITypeLib_Release(*ppTLib);
*ppTLib = NULL;
res = TYPE_E_LIBNOTREGISTERED;
}
}
}
TRACE("(IID: %s) load %s (%p)\n",debugstr_guid(rguid), SUCCEEDED(res)? "SUCCESS":"FAILED", *ppTLib);