bstr: don't call memcpy(..., NULL, 0)

This is clearly not allowed, although it's not a problem on most libcs.

Found by Coverity.
This commit is contained in:
wm4 2014-11-21 05:13:40 +01:00
parent 85fb2af369
commit 9c456ab58f
1 changed files with 2 additions and 0 deletions

View File

@ -379,6 +379,8 @@ static void resize_append(void *talloc_ctx, bstr *s, size_t append_min)
// talloc_ctx will be used as parent context, if s->start is NULL.
void bstr_xappend(void *talloc_ctx, bstr *s, bstr append)
{
if (!append.len)
return;
resize_append(talloc_ctx, s, append.len + 1);
memcpy(s->start + s->len, append.start, append.len);
s->len += append.len;