[PATCH] oledb32: Suport converting to DBTYPE_BYREF | DBTYPE_STR in DataConvert

Huw Davies huw at codeweavers.com
Tue Feb 21 06:44:24 CST 2017


On Wed, Feb 15, 2017 at 04:36:38AM +0000, Alistair Leslie-Hughes wrote:
> Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
> ---
>  dlls/oledb32/convert.c       | 26 ++++++++++++
>  dlls/oledb32/tests/convert.c | 94 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 120 insertions(+)
> 
> diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c
> index 0a1518d9a9..cd4161c886 100644
> --- a/dlls/oledb32/convert.c
> +++ b/dlls/oledb32/convert.c
> @@ -845,6 +845,32 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
>          return hr;
>      }
>  
> +    case DBTYPE_BYREF | DBTYPE_STR:
> +    {
> +        BSTR b;
> +        char **d = dst;
> +        DBLENGTH bstr_len;
> +        hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
> +                                      src, &b, sizeof(BSTR), src_status, dst_status,
> +                                      precision, scale, flags);
> +        if(hr != S_OK) return hr;
> +
> +        bstr_len = SysStringLen(b) * sizeof(char);
> +        *dst_len = bstr_len; /* Doesn't include size for '\0' */

dst_len should be calculated by calling WideCharToMultiByte().  This is also
a bug in the DBTYPE_STR handling above (which I guess is where this came from).

> +        *dst_status = DBSTATUS_S_OK;
> +        *d = CoTaskMemAlloc(bstr_len + sizeof(char));

And this should be dst_len;

It probably makes sense to move this case below DBTYPE_BYREF | DBTYPE_WSTR,
to mirror the order of DBTYPE_WSTR / DBTYPE_STR.

Huw.



More information about the wine-devel mailing list