Commit 42481bda authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Ensure a resized empty buffer is null-terminated.

The new buffer code is using the pool, which ensures its buffers are

However, if a "new" buffer from another part of the code were passed
to one of the temporary interfaces that resizes the buffer, it's
possible a non-terminated string might end up being passed through.

It's reasonable to expect mutt_b2s() for a "new" buffer should be the
same as after it is resized larger.  So ensure the resulting buf->data
is properly terminated to avoid surprises.
parent dd1e0ea4
......@@ -93,6 +93,8 @@ void mutt_buffer_increase_size (BUFFER *buf, size_t new_size)
buf->dsize = new_size;
safe_realloc (&buf->data, buf->dsize);
buf->dptr = buf->data + offset;
/* This ensures an initially NULL buf->data is now properly terminated. */
*(buf->dptr) = '\0';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment