Skip to content

Commit

Permalink
client: fix panic on request failure
Browse files Browse the repository at this point in the history
Fixes the worst of #1186

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Feb 16, 2021
1 parent 5740a1b commit ce11fd7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion httptransport/client/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ func (s *HTTP) AffectedManifests(ctx context.Context, v []claircore.Vulnerabilit
}
resp, err := s.c.Do(req)
if err != nil {
return nil, &clairerror.ErrRequestFail{Code: resp.StatusCode, Status: resp.Status}
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, &clairerror.ErrRequestFail{Code: resp.StatusCode, Status: resp.Status}
}
err = json.NewDecoder(resp.Body).Decode(&affected)
if err != nil {
return nil, &clairerror.ErrBadAffectedManifests{err}
Expand Down

0 comments on commit ce11fd7

Please sign in to comment.