Skip to content

Commit

Permalink
Merge pull request #54 from treydock/delete
Browse files Browse the repository at this point in the history
Avoid nil pointer dereference with errors on Delete
  • Loading branch information
stmcginnis authored Jan 30, 2020
2 parents 1119f8b + 5a8cf19 commit c4ac3c9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ func (c *APIClient) Patch(url string, payload interface{}) (*http.Response, erro
// Delete performs a Delete request against the Redfish service.
func (c *APIClient) Delete(url string) error {
resp, err := c.runRequest("DELETE", url, nil)
resp.Body.Close()
if err != nil {
return err
}
if resp != nil && resp.Body != nil {
resp.Body.Close()
}
return nil
}

Expand Down

0 comments on commit c4ac3c9

Please sign in to comment.