From 35e4c1a7bf186418e43feb91f97b8058722af080 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sat, 12 Mar 2016 16:32:12 -0700 Subject: [PATCH] Sanity checkL this defer does not leak fds; comment added --- middleware/fileserver.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/middleware/fileserver.go b/middleware/fileserver.go index a1efd945..8d9dabcc 100644 --- a/middleware/fileserver.go +++ b/middleware/fileserver.go @@ -103,6 +103,8 @@ func (fh *fileHandler) serveFile(w http.ResponseWriter, r *http.Request, name st index := strings.TrimSuffix(name, "/") + "/" + indexPage ff, err := fh.root.Open(index) if err == nil { + // this defer does not leak fds because previous iterations + // of the loop must have had an err, so nothing to close defer ff.Close() dd, err := ff.Stat() if err == nil {