From 8ba4a2e0f3609800bb671a1e2ba1402651451dcf Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 1 Apr 2015 14:30:22 +1100 Subject: [PATCH] cmd/torrentfs: Check error creating client This wouldn't have happened with exceptions ;) --- client.go | 5 +++++ cmd/torrentfs/main.go | 3 +++ 2 files changed, 8 insertions(+) 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) }) -- 2.48.1