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.
This commit is contained in:
Pierce Lopez
2016-07-16 00:30:31 -04:00
parent 2b255d0ebf
commit 868b20ce4e

View File

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