]> git.ipfire.org Git - thirdparty/json-c.git/commit
printbuf_memset(): set gaps to zero 750/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 3 Mar 2022 20:18:53 +0000 (21:18 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 3 Mar 2022 20:18:53 +0000 (21:18 +0100)
commit63c602ff808f777341b1d9a83b28762b137909a9
treeede964e5f95794516dbfc6dd1088d459802e9e61
parentbd56cc8bf77afa6e2c94cc62539d1fda2d1a86b6
printbuf_memset(): set gaps to zero

It is possible to have a printbuf with "gaps", i.e. areas within the
print buffer which have not been initialized by using printbuf_memset.

Always clear memory in such cases.

Example:
```
struct printbuf *pb = printbuf_new();
printbuf_memset(pb, 10, 'a', 2);
```
In this case pb->buf[0] is '\0' but pb->buf[1] up to pb->buf[9] are
not set. The length would be 12 due to successful printbuf_memset.
printbuf.c