Fix cbuffer initialization

If no data was appended, cbuf_get() would return a pointer to
uninitialized memory. Now it returns a pointer to a string of zero
length.
This commit is contained in:
Tillmann Karras 2012-07-22 20:30:02 +02:00 committed by Jan Vidar Krey
parent f0b11dadf1
commit 16ee65422d

View File

@ -36,6 +36,7 @@ extern struct cbuffer* cbuf_create(size_t capacity)
buf->size = 0; buf->size = 0;
buf->flags = 0; buf->flags = 0;
buf->buf = hub_malloc(capacity + 1); buf->buf = hub_malloc(capacity + 1);
buf->buf[0] = '\0';
return buf; return buf;
} }