From 9264bbbc52ed6b7e1f9af95e129cb1f7e68c355e Mon Sep 17 00:00:00 2001 From: Yao Yue Date: Sat, 1 Apr 2017 16:35:06 -0700 Subject: [PATCH] Zero byte (#147) (emergency fix needed for pelikan) * buf_write return immediately on 0 byte * fix bug --- include/buffer/cc_buf.h | 4 ++++ src/cc_print.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/buffer/cc_buf.h b/include/buffer/cc_buf.h index f0d7924db..4fe111dd3 100644 --- a/include/buffer/cc_buf.h +++ b/include/buffer/cc_buf.h @@ -169,6 +169,10 @@ buf_read(char *dst, struct buf *src, uint32_t count) static inline uint32_t buf_write(struct buf *dst, char *src, uint32_t count) { + if (count == 0) { + return 0; + } + ASSERT(dst != NULL && src != NULL); uint32_t len = MIN(buf_wsize(dst), count); diff --git a/src/cc_print.c b/src/cc_print.c index 22b5ee4ff..8a16430f5 100644 --- a/src/cc_print.c +++ b/src/cc_print.c @@ -60,7 +60,7 @@ cc_print_int64_unsafe(char *buf, int64_t n) } d = digits(ab); - _print_uint64(buf, d, n); + _print_uint64(buf, d, ab); return d + (n < 0); }