From 483109b8fcfd3b3d612907a2c5c08a1d2723cbe2 Mon Sep 17 00:00:00 2001 From: Tom DNetto Date: Mon, 3 Apr 2023 11:14:02 -0700 Subject: [PATCH] client/tailscale: Fix NPE caused by erroneous close in error case Fixes https://github.com/tailscale/tailscale/issues/7572 When handling an error during `StreamDebugCapture`, the response body is closed, even though the response struct is always nil. Thanks to https://github.com/darkrain42 for debugging this!! Signed-off-by: Tom DNetto --- client/tailscale/localclient.go | 1 - 1 file changed, 1 deletion(-) diff --git a/client/tailscale/localclient.go b/client/tailscale/localclient.go index e35846e61..9224f0843 100644 --- a/client/tailscale/localclient.go +++ b/client/tailscale/localclient.go @@ -1101,7 +1101,6 @@ func (lc *LocalClient) StreamDebugCapture(ctx context.Context) (io.ReadCloser, e } res, err := lc.doLocalRequestNiceError(req) if err != nil { - res.Body.Close() return nil, err } if res.StatusCode != 200 {