From 433c1ddac94192df097daecf23d71652a098e1ff Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 2 Apr 2016 13:49:38 +1300 Subject: [PATCH] libnmdc: patch panic() on nil connection --- src/libnmdc/libnmdc.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libnmdc/libnmdc.go b/src/libnmdc/libnmdc.go index 0a3c253..85bfadb 100644 --- a/src/libnmdc/libnmdc.go +++ b/src/libnmdc/libnmdc.go @@ -314,6 +314,7 @@ func (this *HubConnection) processProtocolMessage(message string) { func (this *HubConnection) worker() { var fullBuffer string var err error = nil + var nbytes int = 0 for { @@ -332,10 +333,12 @@ func (this *HubConnection) worker() { } // Read from socket into our local buffer (blocking) - readBuff := make([]byte, 4096) - nbytes, err := this.conn.Read(readBuff) - if nbytes > 0 { - fullBuffer += string(readBuff[0:nbytes]) + if this.conn != nil { + readBuff := make([]byte, 4096) + nbytes, err = this.conn.Read(readBuff) + if nbytes > 0 { + fullBuffer += string(readBuff[0:nbytes]) + } } // Maybe we disconnected