From 7b5f52d77d38d03015de9c9df9bc155fd4b3a259 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sun, 4 Oct 2020 10:45:51 +0000 Subject: [PATCH] Fix: Corrected memory allocator --- src/json.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/json.c b/src/json.c index c25bd0db..7a001b9c 100644 --- a/src/json.c +++ b/src/json.c @@ -48,6 +48,9 @@ static int allocate_buffer(json_renderer_t *renderer, size_t needed) if (!renderer->valid) return 1; + if (have) + have--; + if (have < required) { size_t want; char *n; @@ -65,6 +68,7 @@ static int allocate_buffer(json_renderer_t *renderer, size_t needed) return 1; renderer->buffer = n; + renderer->bufferlen = want; } return 0;