From 256db54c9d25e06297017c3145028ab3ed41b259 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Wed, 19 May 2021 14:22:26 -0400 Subject: [PATCH] ipn: allow b to be nil in NewBackendServer A couple of code paths in ipnserver use a NewBackendServer with a nil backend just to call the callback with an encapsulated error message. This covers a panic case seen in logs. For #1920 Signed-off-by: David Crawshaw --- ipn/message.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ipn/message.go b/ipn/message.go index 7f8d2be21..7080e4e2d 100644 --- a/ipn/message.go +++ b/ipn/message.go @@ -104,7 +104,9 @@ func NewBackendServer(logf logger.Logf, b Backend, sendNotifyMsg func(b []byte)) b: b, sendNotifyMsg: sendNotifyMsg, } - if sendNotifyMsg != nil { + // b may be nil if the BackendServer is being created just to + // encapsulate and send an error message. + if sendNotifyMsg != nil && b != nil { b.SetNotifyCallback(bs.send) } return bs