From 868b20ce4e8ff745ae78c5a5368005d26e865f42 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Sat, 16 Jul 2016 00:30:31 -0400 Subject: [PATCH] initialize null terminator of new printbuf It's possible (e.g. by using json_object_from_file() on an empty file) to get json-c to try to use a printbuf that has never had anything written to it. Before this change, it could access a string that should be length zero, but was never initialized, and could theoretically have an unexpected string. --- printbuf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/printbuf.c b/printbuf.c index fe952b45..a40b89d5 100644 --- a/printbuf.c +++ b/printbuf.c @@ -42,6 +42,7 @@ struct printbuf* printbuf_new(void) free(p); return NULL; } + p->buf[0]= '\0'; return p; } -- 2.39.5