You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
lib/upgrade: HTTP response body leak in FetchLatestReleases on non-2xx status #10635
In lib/upgrade/upgrade_supported.go, the FetchLatestReleases function has a response body leak when the server returns a non-2xx HTTP status code.
funcFetchLatestReleases(releasesURL, currentstring) []Release {
resp, err:=upgradeClientGet(releasesURL, current)
iferr!=nil {
...returnnil
}
ifresp.StatusCode>299 {
slog.Warn("Failed to fetch latest release information", slogutil.Error(resp.Status))
returnnil// <-- resp.Body is never closed here
}
...resp.Body.Close()
returnrels
}
When the response status code is > 299 (e.g. 429 Too Many Requests, 503 Service Unavailable), the function returns nil without calling resp.Body.Close(). According to the Go net/http docs, the caller must close the response body to allow the underlying TCP connection to be reused by the HTTP client's connection pool. Failing to do so leaks a goroutine and the connection until the GC eventually finalizes it.
Impact
HTTP connection pool connections are not reused after a failed release check, slowly exhausting available connections under load or on flaky networks.
Goroutines associated with the response body may be leaked briefly.
Fix
Add defer resp.Body.Close() immediately after the successful Do() call and remove the later explicit close, so all return paths are covered.
Activity
chore: trivial fixes (syncthing#10650)
[codex] Merge upstream stable v2.1.1 into main (#23)