patch to fix bug 8246
Hin-Tak Leung
htl10 at users.sourceforge.net
Tue Mar 11 14:10:52 CDT 2008
I did wonder what the padding was about (it didn't do any harm...) -
I'll be happy to rework it to make it acceptable.
--- Andrey Turkin <andrey.turkin at gmail.com> wrote:
> This is not about embedded nulls, this is about possibly not null terminated
> strings. If there is zero somewhere in the buffer then we should only
> convert string up to that zero; if there isn't any nulls, then we have to
> convert full string and null-terminate string. This can be coded prettier,
> though:
>
> if (l>0)
> {
> void *eos = memchr(str, 0, l);
> if (eos)
> l = (LONG)(eos-str);
> }
>
> and always zero-pad afterwards
>
> 2008/3/11, Alexandre Julliard <julliard at winehq.org>:
> >
> > Hin-Tak Leung <htl10 at users.sourceforge.net> writes:
> >
> > > This is the fix to bug 8246 to get HtmlHelpW to work correctly.
> > > It was first worked on by Andrey Turkin and updated later by me.
> >
> >
> > Please add a proper log entry describing the change.
> >
> > > -static inline LPWSTR strdupAtoW(LPCSTR str)
> > > +static inline LPWSTR strdupnAtoW(LPCSTR str, LONG l)
> > > {
> > > LPWSTR ret;
> > > DWORD len;
> > > + BOOL zero_pad;
> > >
> > > if(!str)
> > > return NULL;
> > >
> > > - len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
> > > + if (l>0)
> > > + {
> > > + LONG i;
> > > + zero_pad = TRUE;
> > > + for (i=0;i<l;i++)
> > > + {
> > > + if (!str[i])
> > > + {
> > > + zero_pad = FALSE;
> > > + l = i+1;
> > > + break;
> > > + }
> > > + }
> > > + } else {
> > > + zero_pad = FALSE;
> > > + }
> > > +
> > > + len = MultiByteToWideChar(CP_ACP, 0, str, l, NULL, 0);
> > > + if (zero_pad)
> > > + len++;
> >
> > This is ugly and unnecessary, MultiByteToWideChar handles embedded nulls
> > just fine.
> >
> >
> > --
> > Alexandre Julliard
> > julliard at winehq.org
> >
> >
> >
>
___________________________________________________________
Rise to the challenge for Sport Relief with Yahoo! For Good
http://uk.promotions.yahoo.com/forgood/
More information about the wine-devel
mailing list