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

Backports: #1188
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Feb 17, 2021
1 parent 8a392f1 commit 8b63953
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions httptransport/client/indexer.go
Expand Up @@ -42,6 +42,10 @@ func (s *HTTP) AffectedManifests(ctx context.Context, v []claircore.Vulnerabilit
defer resp.Body.Close()
}
if err != nil {
return affected, fmt.Errorf("request failed: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return affected, &clairerror.ErrRequestFail{Code: resp.StatusCode, Status: resp.Status}
}
err = json.NewDecoder(resp.Body).Decode(&affected)
Expand Down

0 comments on commit 8b63953

Please sign in to comment.