Don't pass in buffer directly to writer
The io.Writer interface specifies that implementations must not retain p [1]. However, we have many places in the code that pass in the buffer directly to a streamio.Writer. Find places where we do this and make sure we pass in a copy of the data instead.
fixes: #6129