Skip to content

Commit

Permalink
Only write buffer if it is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Jan 22, 2024
1 parent 8e255ec commit 5c3a05e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions wire/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,10 @@ func WriteMessageWithEncodingN(w io.Writer, msg Message, pver uint32,
// Write header and payload in 1 go.
// This w.Write() is locking, so we don't have to worry about concurrent writes.
var n int
n, err = w.Write(append(hw.Bytes(), payload...))
totalBytes += n
if hw != nil {
n, err = w.Write(append(hw.Bytes(), payload...))
totalBytes += n
}

return totalBytes, err
}
Expand Down

0 comments on commit 5c3a05e

Please sign in to comment.