From: Pierce Lopez Date: Sat, 16 Jul 2016 04:30:31 +0000 (-0400) Subject: initialize null terminator of new printbuf X-Git-Tag: json-c-0.13-20171207~146^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F239%2Fhead;p=thirdparty%2Fjson-c.git 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. --- 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; }