From a84cd9da0933d6a73087fbd5e1c6cabbd554649f Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 21 Nov 2016 12:39:38 +0000 Subject: [PATCH] fixed a bug in logfmt.c --- lib/logfmt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/logfmt.c b/lib/logfmt.c index e67fdef..b7ae279 100644 --- a/lib/logfmt.c +++ b/lib/logfmt.c @@ -276,11 +276,12 @@ static int put_oocs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_ } newcapa = HCL_ALIGN(hcl->log.len + len, 512); /* TODO: adjust this capacity */ - tmp = hcl_reallocmem (hcl, hcl->log.ptr, newcapa * HCL_SIZEOF(*tmp)); + /* +1 to handle line ending injection more easily */ + tmp = hcl_reallocmem (hcl, hcl->log.ptr, (newcapa + 1) * HCL_SIZEOF(*tmp)); if (!tmp) return -1; hcl->log.ptr = tmp; - hcl->log.capa = newcapa - 1; /* -1 to handle line ending injection more easily */ + hcl->log.capa = newcapa; } HCL_MEMCPY (&hcl->log.ptr[hcl->log.len], ptr, len * HCL_SIZEOF(*ptr));