[PATCH] oledb32: Support DBTYPE_I4->DBTYPE_WSTR in GetConversionSize

Huw Davies huw at codeweavers.com
Fri Jun 16 04:10:48 CDT 2017


On Tue, Jun 13, 2017 at 04:09:54AM +0000, Alistair Leslie-Hughes wrote:
> dst_len cannot be set to 110 beacuse we don't have any idea of how this
> value is set.

In this case we really do want to set something, and if it's 110 on Windows
then we may as well use that.  The previous case was to do with a NULL-variant,
where DataConvert() didn't actually return any data.   This time it will, so we
should give the app a chance to allocate a big enough buffer.

It would also be worth handling and testing more cases than the conversion to DBTYPE_I4.
Perhaps we should set *dst_len to 110 if get_length() returns 0 and then let the special
cases overrride it.

Huw.

> 
> Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> ---
>  dlls/oledb32/convert.c       |  5 +++++
>  dlls/oledb32/tests/convert.c | 12 ++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
> index 0d45ef0..bf01101 100644
> --- a/dlls/oledb32/convert.c
> +++ b/dlls/oledb32/convert.c
> @@ -1401,6 +1401,11 @@ static HRESULT WINAPI convert_GetConversionSize(IDataConvert* iface,
>      case DBTYPE_WSTR:
>          switch (src_type)
>          {
> +        case DBTYPE_I4:
> +        {
> +            /* Return S_OK to signal we can convert from this type. On windows, dst_len is set to 110. */
> +            break;
> +        }
>          case DBTYPE_VARIANT:
>          {
>              VARIANT v;
> diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
> index 116ca16..d07ebf1 100644
> --- a/dlls/oledb32/tests/convert.c
> +++ b/dlls/oledb32/tests/convert.c
> @@ -2715,6 +2715,7 @@ static void test_getconversionsize(void)
>      VARIANT var;
>      SAFEARRAY *psa = NULL;
>      SAFEARRAYBOUND rgsabound[1];
> +    int i4;
>  
>      /* same way as CanConvert fails here */
>      dst_len = 0;
> @@ -2834,6 +2835,17 @@ static void test_getconversionsize(void)
>      ok(dst_len == 1802, "%ld\n", dst_len);
>      VariantClear(&var);
>  
> +    /* A value of 110 is returned in dst_len */
> +    dst_len = 0;
> +    src_len = sizeof(i4);
> +    i4 = 200;
> +    hr = IDataConvert_GetConversionSize(convert, DBTYPE_I4, DBTYPE_WSTR, &src_len, &dst_len, &i4);
> +    ok(hr == S_OK, "got 0x%08x\n", hr);
> +
> +    dst_len = 0;
> +    hr = IDataConvert_GetConversionSize(convert, DBTYPE_I4, DBTYPE_WSTR, NULL, &dst_len, NULL);
> +    ok(hr == S_OK, "got 0x%08x\n", hr);
> +
>      /* 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.
>       */
> -- 
> 1.9.1
> 
> 
> 



More information about the wine-devel mailing list