Commit e5daf339 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

oledb32: GetConversionSize shouldn't fail for null variants.

If we have a NULL variant which will be converted to a non-fixed sized type (DBTYPE_WSTR) then we just return S_OK. Signed-off-by: 's avatarAlistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6d216964
......@@ -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:
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment