mirror of
https://github.com/json-c/json-c.git
synced 2026-03-24 07:29:07 +08:00
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:
@@ -42,6 +42,7 @@ struct printbuf* printbuf_new(void)
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
p->buf[0]= '\0';
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user