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 <tom@tailscale.com>
This commit is contained in:
Tom DNetto 2023-04-03 11:14:02 -07:00 committed by Tom
parent 59879e5770
commit 483109b8fc

View File

@ -1101,7 +1101,6 @@ func (lc *LocalClient) StreamDebugCapture(ctx context.Context) (io.ReadCloser, e
} }
res, err := lc.doLocalRequestNiceError(req) res, err := lc.doLocalRequestNiceError(req)
if err != nil { if err != nil {
res.Body.Close()
return nil, err return nil, err
} }
if res.StatusCode != 200 { if res.StatusCode != 200 {