Fix bug in strbuf_reset()

Could write a nul char into a zero-size buffer.
This commit is contained in:
Andrew Bettison 2015-11-17 00:13:22 +10:30
parent 23cd578595
commit fc67b38fd2

View File

@ -35,8 +35,8 @@ strbuf strbuf_init(strbuf sb, char *buffer, ssize_t size)
strbuf strbuf_reset(strbuf sb)
{
sb->current = sb->start;
if (sb->start)
*sb->start = '\0';
if (sb->current && (!sb->end || (sb->current <= sb->end)))
*sb->current = '\0';
return sb;
}