Skip to content

Commit

Permalink
Avoid segfault with nil error handlers in ws
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Nov 17, 2024
1 parent 8686c4a commit 88a0911
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/network/websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ func (c *Connection) reader() {
_, message, err := c.conn.ReadMessage()
if err != nil {
if websocket.IsUnexpectedCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) {
c.errorHandler(err)
if c.errorHandler != nil {
c.errorHandler(err)
}
} else {
c.callback(message, err)
}
Expand Down

0 comments on commit 88a0911

Please sign in to comment.