diff --git a/dlls/oleaut32/tests/safearray.c b/dlls/oleaut32/tests/safearray.c index 689494d0f10..97ba9dd72f1 100644 --- a/dlls/oleaut32/tests/safearray.c +++ b/dlls/oleaut32/tests/safearray.c @@ -1683,9 +1683,18 @@ static void test_SafeArrayChangeTypeEx(void) VariantInit(&v2); hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_BSTR); - ok(hres != S_OK, "CTE VT_ARRAY|VT %d->BSTR succeeded\n", vt); + if (vt == VT_INT_PTR || vt == VT_UINT_PTR) + { + ok(hres == DISP_E_BADVARTYPE, "expected DISP_E_BADVARTYPE, got 0x%08x\n", hres); + SafeArrayDestroy(sa); + } + else + { + ok(hres == DISP_E_TYPEMISMATCH, "got 0x%08x for vt=%d, instead of DISP_E_TYPEMISMATCH\n", hres, vt); + hres = VariantClear(&v); + ok(hres == S_OK, "expected S_OK, got 0x%08x\n", hres); + } VariantClear(&v2); - VariantClear(&v); } /* Can't change an array of one type into array of another type , even diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 776c0e7bd4a..5d32c3b07a6 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -652,7 +652,7 @@ HRESULT VARIANT_ClearInd(VARIANTARG *pVarg) */ HRESULT WINAPI VariantClear(VARIANTARG* pVarg) { - HRESULT hres = S_OK; + HRESULT hres; TRACE("(%p->(%s%s))\n", pVarg, debugstr_VT(pVarg), debugstr_VF(pVarg)); @@ -664,8 +664,7 @@ HRESULT WINAPI VariantClear(VARIANTARG* pVarg) { if (V_ISARRAY(pVarg) || V_VT(pVarg) == VT_SAFEARRAY) { - if (V_ARRAY(pVarg)) - hres = SafeArrayDestroy(V_ARRAY(pVarg)); + hres = SafeArrayDestroy(V_ARRAY(pVarg)); } else if (V_VT(pVarg) == VT_BSTR) {