Skip to content

Commit

Permalink
Check RemoteAddr isn't nil before deref
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Jun 15, 2023
1 parent c546321 commit ff3505d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/net/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,9 @@ func isCommonNetReadError(err error) bool {

// Serve a new connection.
func (c *conn) serve(ctx context.Context) {
c.remoteAddr = c.rwc.RemoteAddr().String()
if ra := c.rwc.RemoteAddr(); ra != nil {
c.remoteAddr = ra.String()
}
ctx = context.WithValue(ctx, LocalAddrContextKey, c.rwc.LocalAddr())
var inFlightResponse *response
defer func() {
Expand Down

0 comments on commit ff3505d

Please sign in to comment.