[PATCH 5/7] [v2] wsdapi: Build and write Scopes and XAddrs lists for Hello message.

Huw Davies huw at codeweavers.com
Tue Apr 24 03:25:40 CDT 2018


On Tue, Apr 24, 2018 at 08:20:27AM +0000, Owen Rudge wrote:
> Hi Huw,
> 
> > > +    do
> > > +    {
> > > +        /* Calculate space needed, including trailing space */
> > > +        string_len = lstrlenW(cur->Element);
> > > +        memory_needed = (string_len + 1) * sizeof(WCHAR);
> > 
> > Should be one WCHAR more to allow for the ' ';
> 
> In this case, I think the code is correct - if there is a trailing space, then there won't be a null character after it (as we'll have another URL following the space). If it's the last entry in the list, then instead of a trailing space there will be a null character.
> 
> > > +        if (cur_buf_pos + memory_needed > buffer + buffer_size)
> > > +            return E_INVALIDARG;
> > > +
> > > +        if (cur != list)
> > > +            *cur_buf_pos++ = ' ';
> > > +
> > > +        memcpy(cur_buf_pos, cur->Element, memory_needed);
> >
> > And the memcpy size would then need to be (string_len + 1) * sizeof(WCHAR)
> 
> In this case the null character is being copied as part of the memcpy statement, then is being replaced by the space on the following loop iteration (when cur != list).
> 

Right, got it.

Signed-off-by: Huw Davies <huw at codeweavers.com>



More information about the wine-devel mailing list