From: Matt Joiner <anacrolix@gmail.com>
Date: Wed, 1 Apr 2015 03:30:22 +0000 (+1100)
Subject: cmd/torrentfs: Check error creating client
X-Git-Tag: v1.0.0~1221
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=8ba4a2e0f3609800bb671a1e2ba1402651451dcf;p=btrtrc.git

cmd/torrentfs: Check error creating client

This wouldn't have happened with exceptions ;)
---

diff --git a/client.go b/client.go
index ed037c6c..981d4d22 100644
--- a/client.go
+++ b/client.go
@@ -491,6 +491,11 @@ func NewClient(cfg *Config) (cl *Client, err error) {
 		cfg = &Config{}
 	}
 
+	defer func() {
+		if err != nil {
+			cl = nil
+		}
+	}()
 	cl = &Client{
 		noUpload:        cfg.NoUpload,
 		disableTrackers: cfg.DisableTrackers,
diff --git a/cmd/torrentfs/main.go b/cmd/torrentfs/main.go
index a7e786ae..03edc857 100644
--- a/cmd/torrentfs/main.go
+++ b/cmd/torrentfs/main.go
@@ -103,6 +103,9 @@ func main() {
 		ListenAddr: *listenAddr,
 		NoUpload:   true, // Ensure that uploads are responsive.
 	})
+	if err != nil {
+		log.Fatal(err)
+	}
 	http.DefaultServeMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
 		client.WriteStatus(w)
 	})