[PATCH] oleaut32: Fix some corner cases in VarBstrCmp.

Alexandre Julliard julliard at winehq.org
Tue Aug 5 05:15:41 CDT 2008


"Lei Zhang" <thestig at google.com> writes:

> diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c
> index daeac85..713ebae 100644
> --- a/dlls/oleaut32/vartype.c
> +++ b/dlls/oleaut32/vartype.c
> @@ -6942,7 +6942,24 @@ HRESULT WINAPI VarBstrCmp(BSTR pbstrLeft, BSTR pbstrRight, LCID lcid, DWORD dwFl
>      if (!pbstrLeft || !*pbstrLeft)
>      {
>        if (!pbstrRight || !*pbstrRight)
> -        return VARCMP_EQ;
> +      {
> +        UINT ll;
> +        UINT lr;
> +
> +        if (lcid)
> +        {
> +          ll = SysStringLen(pbstrLeft);
> +          lr = SysStringLen(pbstrRight);
> +        }
> +        else
> +        {
> +          ll = SysStringByteLen(pbstrLeft);
> +          lr = SysStringByteLen(pbstrRight);
> +        }
> +        if (ll == lr)
> +          return VARCMP_EQ;
> +        return ll < lr ? VARCMP_LT : VARCMP_GT;
> +      }

That's ugly, you shouldn't need such special handling here, you should
simply fall through to the normal comparisons which should give the
correct results.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list