Skip to content

Commit

Permalink
VAULT-20403 fix incorrectly deferred resource closure in debug command (
Browse files Browse the repository at this point in the history
#26167)

* VAULT-20403 fix incorrectly deferred resource closure in debug command

* VAULT-20403 changelog
  • Loading branch information
VioletHynes authored Mar 27, 2024
1 parent 5fac327 commit 2a33300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/26167.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli/debug: Fix resource leak in CLI debug command.
```
5 changes: 3 additions & 2 deletions command/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,17 +687,18 @@ func (c *DebugCommand) collectHostInfo(ctx context.Context) {
return
}
if resp != nil {
defer resp.Body.Close()

secret, err := api.ParseSecret(resp.Body)
if err != nil {
c.captureError("host", err)
resp.Body.Close()
return
}
if secret != nil && secret.Data != nil {
hostEntry := secret.Data
c.hostInfoCollection = append(c.hostInfoCollection, hostEntry)
}

resp.Body.Close()
}
}
}
Expand Down

0 comments on commit 2a33300

Please sign in to comment.