diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index 8525c6c571a..f2c4c29bad5 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -1108,6 +1108,12 @@ static HRESULT WINAPI convert_GetConversionSize(IDataConvert* iface, { switch (src_type) { + case DBTYPE_STR: + if(src_len) + *dst_len = (*src_len + 1) * sizeof(WCHAR); + else + *dst_len = (strlen(src) + 1) * sizeof(WCHAR); + break; case DBTYPE_WSTR: if(src_len) *dst_len = (*src_len) + sizeof(WCHAR); diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index d1f6c4ed6d0..51dc0f6e132 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -2484,6 +2484,7 @@ static void test_getconversionsize(void) HRESULT hr; BSTR str; static WCHAR strW[] = {'t','e','s','t',0}; + static char strTest[] = "test"; hr = CoCreateInstance(&CLSID_OLEDB_CONVERSIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IDataConvert, (void**)&convert); if(FAILED(hr)) @@ -2530,6 +2531,23 @@ static void test_getconversionsize(void) ok(hr == S_OK, "got 0x%08x\n", hr); ok(dst_len == 22, "%ld\n", dst_len); + dst_len = 0; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, NULL, &dst_len, strTest); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(dst_len == 10 || broken(dst_len == 12), "%ld\n", dst_len); + + dst_len = 0; + src_len = 2; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, &src_len, &dst_len, strTest); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(dst_len == 6, "%ld\n", dst_len); + + dst_len = 0; + src_len = 20; + hr = IDataConvert_GetConversionSize(convert, DBTYPE_STR, DBTYPE_WSTR, &src_len, &dst_len, strTest); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(dst_len == 42, "%ld\n", dst_len); + IDataConvert_Release(convert); }