diff --git a/buffer.c b/buffer.c index 01af0dd..2b35f72 100644 --- a/buffer.c +++ b/buffer.c @@ -99,7 +99,9 @@ buffer* buf_newcopy(buffer* buf) { ret = buf_new(buf->len); ret->len = buf->len; - memcpy(ret->data, buf->data, buf->len); + if (buf->len > 0) { + memcpy(ret->data, buf->data, buf->len); + } return ret; }