windows: Avoid leak of write buffer on realloc failure.
VS2019 IntelliSense reported:
Warning C6308: 'realloc' might return null pointer: assigning null
pointer to 'port->write_buf', which is passed as an
argument to 'realloc', will cause the original memory
block to be leaked.
This is correct, we would leak the buffer on a realloc failure.
Put the realloc result in a separate variable and handle the error
path before assigning the result to port->write_buf.