Subject: [PATCH] Check before closing potentially nil channel

From: Emery Hemingway <[email-masked]>
Date: Fri, 28 Oct 2022 15:05:24 +0000

I had a problem here when the nncp-daemon starts up with while being
spammed by new connection requests.

---
 src/cmd/nncp-daemon/main.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/cmd/nncp-daemon/main.go b/src/cmd/nncp-daemon/main.go
index 710b687..39b25c4 100644
--- a/src/cmd/nncp-daemon/main.go
+++ b/src/cmd/nncp-daemon/main.go
@@ -310,7 +310,9 @@ func main() {
                        }
                        <-nodeIdC // call completion
                        if *autoToss {
-                               close(autoTossFinish)
+                               if autoTossFinish != nil {
+                                       close(autoTossFinish)
+                               }
                                <-autoTossBadCode
                        }
                        conn.Close()
-- 
2.37.3