From f24a5f23f52eb2d877041ad977b498a980ae6f85 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Thu, 7 Nov 2024 21:08:09 +0000 Subject: [PATCH] buf.c: fix off by one bug in buf_add_char() Written-by: @johanmalm Fixes: #2313 Backported from 7e50c60b003618729554777e61abda6ca935dc4b --- src/common/buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/buf.c b/src/common/buf.c index ecdddc6e..76f5c833 100644 --- a/src/common/buf.c +++ b/src/common/buf.c @@ -111,7 +111,7 @@ buf_add(struct buf *s, const char *data) void buf_add_char(struct buf *s, char ch) { - buf_expand(s, s->len + 1); + buf_expand(s, s->len + 2); s->data[s->len++] = ch; s->data[s->len] = '\0'; }