common: Fix put_membuf.

* common/membuf.c (put_membuf): Allow NULL for the second arg.

--

There has been such a use case in keybox-blob.c.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2021-08-27 16:55:25 +09:00
parent c4ba712736
commit f271c69164
1 changed files with 4 additions and 1 deletions

View File

@ -111,7 +111,10 @@ put_membuf (membuf_t *mb, const void *buf, size_t len)
}
mb->buf = p;
}
memcpy (mb->buf + mb->len, buf, len);
if (buf)
memcpy (mb->buf + mb->len, buf, len);
else
memset (mb->buf + mb->len, 0, len);
mb->len += len;
}