msi [6/10]: pcchValue represents the length of szValue in TCHARS, not bytes

James Hawkins truiken at gmail.com
Mon Jul 2 15:11:50 CDT 2007


On 7/2/07, Alexandre Julliard <julliard at winehq.org> wrote:
> "James Hawkins" <truiken at gmail.com> writes:
>
> > @@ -341,10 +341,15 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWS
> >      }
> >      else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
> >      {
> > +        *pcchValue = *pcchValue * sizeof(WCHAR);
> >          rc = RegQueryValueExW(sourcekey, INSTALLPROPERTY_PACKAGENAMEW, 0, 0,
> > -                (LPBYTE)szValue, pcchValue);
> > +                              (LPBYTE)szValue, pcchValue);
> >          if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA)
> >              rc = ERROR_SUCCESS;
> > +        if (*pcchValue)
> > +            *pcchValue = (*pcchValue - 1) / sizeof(WCHAR);
> > +        if (szValue)
> > +            szValue[*pcchValue] = '\0';
>
> You shouldn't use the results if the registry function failed. Also
> there isn't much point in checking pcchValue for NULL since you
> accessed it already.
>

The check is for the value of *pcchValue, not the pointer itself.  If
the length is zero, we should leave it at zero, but if the length of
the value is not zero, we need to subtract one for the null
terminator.  I will resend with the fix for the error case though.

-- 
James Hawkins



More information about the wine-devel mailing list