Check RemoteAddr isn't nil before deref

This commit is contained in:
Al Cutter 2023-06-15 15:29:13 +01:00
parent c5463218a2
commit ff3505d1d0
1 changed files with 3 additions and 1 deletions

View File

@ -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() {