]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
initialize null terminator of new printbuf 239/head
authorPierce Lopez <pierce.lopez@gmail.com>
Sat, 16 Jul 2016 04:30:31 +0000 (00:30 -0400)
committerPierce Lopez <pierce.lopez@gmail.com>
Sat, 16 Jul 2016 04:30:31 +0000 (00:30 -0400)
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

index fe952b4522d91ce44c3f7c4b67b1b79c8a64f98a..a40b89d577453ab468bc2f88177f7649a773b0e4 100644 (file)
@@ -42,6 +42,7 @@ struct printbuf* printbuf_new(void)
     free(p);
     return NULL;
   }
+  p->buf[0]= '\0';
   return p;
 }