X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/f0e5040e02adc26e25cb54cd345fd3989b25f0a3..945b98135dceeebc524fd7fc557204c80f09c21d:/hotline/server.go diff --git a/hotline/server.go b/hotline/server.go index 164b93e..bd15a2e 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -565,8 +565,13 @@ func (s *Server) handleNewConnection(ctx context.Context, rwc io.ReadWriteCloser scanner.Scan() + // Make a new []byte slice and copy the scanner bytes to it. This is critical to avoid a data race as the + // scanner re-uses the buffer for subsequent scans. + buf := make([]byte, len(scanner.Bytes())) + copy(buf, scanner.Bytes()) + var clientLogin Transaction - if _, err := clientLogin.Write(scanner.Bytes()); err != nil { + if _, err := clientLogin.Write(buf); err != nil { return err }