diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index 891b31c1bd5..0a1518d9a92 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -1344,6 +1344,9 @@ static HRESULT WINAPI convert_GetConversionSize(IDataConvert* iface, if ((*dst_len = get_length(dst_type))) return S_OK; + if(src_type == DBTYPE_VARIANT && V_VT((VARIANT*)src) == VT_NULL) + return S_OK; + switch (dst_type) { case DBTYPE_STR: diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index a7854577a3a..46719b19197 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -2631,16 +2631,25 @@ static void test_getconversionsize(void) src_len = 20; V_VT(&var) = VT_BSTR; V_BSTR(&var) = SysAllocString(strW); - hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_BYTES, &src_len, &dst_len, &var); + hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_STR, &src_len, &dst_len, &var); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(dst_len == 5, "%ld\n", dst_len); + VariantClear(&var); + + src_len = 20; + V_VT(&var) = VT_I4; + V_I4(&var) = 4; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_STR, &src_len, &dst_len, &var); ok(hr == S_OK, "got 0x%08x\n", hr); - ok(dst_len == 2, "%ld\n", dst_len); VariantClear(&var); dst_len = 0; src_len = 20; - V_VT(&var) = VT_NULL; + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(strW); hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_BYTES, &src_len, &dst_len, &var); ok(hr == S_OK, "got 0x%08x\n", hr); + ok(dst_len == 2, "%ld\n", dst_len); VariantClear(&var); dst_len = 0; @@ -2655,6 +2664,30 @@ static void test_getconversionsize(void) ok(hr == S_OK, "got 0x%08x\n", hr); ok(dst_len == 1802, "%ld\n", dst_len); VariantClear(&var); + + /* On Windows, NULL variants being convert to a non-fixed sized type will return a dst_len of + * 110 but we aren't testing for this value. + */ + dst_len = 32; + V_VT(&var) = VT_NULL; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_I4, NULL, &dst_len, &var); + ok(dst_len == 4, "%ld\n", dst_len); + ok(hr == S_OK, "got 0x%08x\n", hr); + + V_VT(&var) = VT_NULL; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_STR, NULL, &dst_len, &var); + ok(hr == S_OK, "got 0x%08x\n", hr); + + V_VT(&var) = VT_NULL; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_WSTR, NULL, &dst_len, &var); + ok(hr == S_OK, "got 0x%08x\n", hr); + + src_len = 20; + V_VT(&var) = VT_NULL; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_VARIANT, DBTYPE_BYTES, &src_len, &dst_len, &var); + ok(hr == S_OK, "got 0x%08x\n", hr); + VariantClear(&var); + } static void test_converttobytes(void)