We only reallocate the buffer to larger size, so I don't see how we can write past the allocated memory. Still, we potentially miss some opportunities to reuse the buffer, so better tracking of the size seems good to me, but the commit message could be adjusted.