summaryrefslogtreecommitdiff
path: root/src/protocol/internal/buffer.c
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-05-21 14:32:34 +0800
committerIru Cai <mytbk920423@gmail.com>2018-05-21 16:45:38 +0800
commitb44293b115bbe69033ab9c066d301e1f7aaf64cf (patch)
tree51a8f7474b5621b25b459513b1444e96dd279242 /src/protocol/internal/buffer.c
parent9f00a9265c05dc02ad1b1e4c8148e1950c394530 (diff)
downloadfqterm-b44293b115bbe69033ab9c066d301e1f7aaf64cf.tar.xz
buffer_append: support NULL argument s to just allocate the space
Diffstat (limited to 'src/protocol/internal/buffer.c')
-rw-r--r--src/protocol/internal/buffer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/protocol/internal/buffer.c b/src/protocol/internal/buffer.c
index f75d33e..dc53781 100644
--- a/src/protocol/internal/buffer.c
+++ b/src/protocol/internal/buffer.c
@@ -51,7 +51,8 @@ static int ensure(buffer *b, size_t len)
int buffer_append(buffer *b, const uint8_t *s, size_t len)
{
if (ensure(b, len)) {
- memcpy(b->p + b->offs + b->sz, s, len);
+ if (s != NULL)
+ memcpy(b->p + b->offs + b->sz, s, len);
b->sz += len;
return 1;
} else {