The provided buffer is already null-terminated by finish_buffer, even in error cases, there is no need to repeat the same work.