Do not write beyond the bounds of the buffer.

When buffer->data != buffer->start, the region after pbuffer_end(buffer)
only counts for a part of the pbuffer_unused. In that case, the memset
would write cause an out-of-bounds write.