From 8305abdab7b9ed6aa193a85ba69a39a12685b7f6 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 24 Dec 2010 02:04:38 +0300 Subject: [PATCH] oleaut32: Fix ICreateTypeInfo2::SetVarHelpContext() to iterate properly. --- dlls/oleaut32/tests/typelib.c | 50 +++++++++++++++++++++++++++++++++++++++++++ dlls/oleaut32/typelib2.c | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index aab340edbda..4b91a6ac4b4 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -2874,6 +2874,55 @@ static void test_LoadTypeLib(void) ok(hres == TYPE_E_CANTLOADLIBRARY, "LoadTypeLib returned: %08x, expected TYPE_E_CANTLOADLIBRARY\n", hres); } +static void test_SetVarHelpContext(void) +{ + static OLECHAR nameW[] = {'n','a','m','e',0}; + CHAR filenameA[MAX_PATH]; + WCHAR filenameW[MAX_PATH]; + ICreateTypeLib2 *ctl; + ICreateTypeInfo *cti; + VARDESC desc; + HRESULT hr; + VARIANT v; + + GetTempFileNameA(".", "tlb", 0, filenameA); + MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH); + + hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl); + ok(hr == S_OK, "got %08x\n", hr); + + hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ENUM, &cti); + ok(hr == S_OK, "got %08x\n", hr); + + hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 0); + ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr); + + memset(&desc, 0, sizeof(desc)); + desc.elemdescVar.tdesc.vt = VT_INT; + desc.varkind = VAR_CONST; + + V_VT(&v) = VT_INT; + V_INT(&v) = 1; + U(desc).lpvarValue = &v; + hr = ICreateTypeInfo2_AddVarDesc(cti, 0, &desc); + ok(hr == S_OK, "got %08x\n", hr); + + hr = ICreateTypeInfo2_SetVarHelpContext(cti, 0, 0); + ok(hr == S_OK, "got %08x\n", hr); + + /* another time */ + hr = ICreateTypeInfo2_SetVarHelpContext(cti, 0, 1); + ok(hr == S_OK, "got %08x\n", hr); + + /* wrong index now */ + hr = ICreateTypeInfo2_SetVarHelpContext(cti, 1, 0); + ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr); + + ICreateTypeInfo_Release(cti); + ICreateTypeLib2_Release(ctl); + DeleteFileA(filenameA); +} + START_TEST(typelib) { const char *filename; @@ -2890,6 +2939,7 @@ START_TEST(typelib) test_QueryPathOfRegTypeLib(64); test_inheritance(); test_CreateTypeLib(); + test_SetVarHelpContext(); if ((filename = create_test_typelib(2))) { diff --git a/dlls/oleaut32/typelib2.c b/dlls/oleaut32/typelib2.c index 8fc8a92b1ba..38ef5452bdb 100644 --- a/dlls/oleaut32/typelib2.c +++ b/dlls/oleaut32/typelib2.c @@ -2553,7 +2553,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetVarHelpContext( if ((This->typeinfo->cElement >> 16) <= index) return TYPE_E_ELEMENTNOTFOUND; - for (iter = This->typedata->next->next; iter != This->typedata; iter = iter->next) + for (iter = This->typedata->next->next; iter != This->typedata->next; iter = iter->next) if (iter->type == CyclicListVar) { if (index-- == 0) -- 2.11.4.GIT