[PATCH] msado15: Account for terminating null in ReadText() (Coverity).
Nikolay Sivov
nsivov at codeweavers.com
Fri Jan 3 15:06:56 CST 2020
On 1/3/20 11:56 PM, Alexandre Julliard wrote:
> Nikolay Sivov <nsivov at codeweavers.com> writes:
>
>> @@ -424,7 +424,7 @@ static HRESULT WINAPI stream_ReadText( _Stream *iface, LONG len, BSTR *ret )
>> if (len == adReadAll) len = (stream->size - stream->pos) / sizeof(WCHAR);
>> else len = min( len, stream->size - stream->pos / sizeof(WCHAR) );
>>
>> - if (!(str = SysAllocStringLen( NULL, len ))) return E_OUTOFMEMORY;
>> + if (!(str = SysAllocStringLen( NULL, len + 1 ))) return E_OUTOFMEMORY;
>> memcpy( str, stream->buf + stream->pos, len * sizeof(WCHAR) );
>> str[len] = 0;
> SysAllocStringLen() already adds the final null.
>
Right, I missed that. In this case explicit termination after memcpy()
is redundant, but harmless, it's easier to leave it as is.
More information about the wine-devel
mailing list