From: Joshua Rubin Date: Fri, 27 Oct 2017 07:47:08 +0000 (-0600) Subject: net/http: fix minor leak in Header.WriteSubset X-Git-Tag: go1.10beta1~564 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a4d03a9bf7604b727abd0a1ebfb118ff6366ee50;p=gostls13.git net/http: fix minor leak in Header.WriteSubset Header.WriteSubset uses a sync.Pool but wouldn't Put the sorter back in the pool if there was an error writing to the io.Writer I'm not really sure why the sorter is returned to begin with. The comment says "for possible return to headerSorterCache". This also doesn't address potential panics that might occur, but the overhead of doing the Put in a defer would likely be too great. Change-Id: If3c45a4c3e11f6ec65d187e25b63455b0142d4e3 Reviewed-on: https://go-review.googlesource.com/73910 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Tom Bergan --- diff --git a/src/net/http/header.go b/src/net/http/header.go index 832169247f..622ad28963 100644 --- a/src/net/http/header.go +++ b/src/net/http/header.go @@ -156,6 +156,7 @@ func (h Header) WriteSubset(w io.Writer, exclude map[string]bool) error { v = textproto.TrimString(v) for _, s := range []string{kv.key, ": ", v, "\r\n"} { if _, err := ws.WriteString(s); err != nil { + headerSorterPool.Put(sorter) return err } }