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: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2015-12-23 17:47:48 +11:00 committed by Alexandre Julliard
parent 6d2169649e
commit e5daf33978
2 changed files with 39 additions and 3 deletions

View file

@ -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:

View file

@ -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)