Skip to content

Commit

Permalink
Merge pull request #238 from cloudbase/fix-nil-pointer-dereference
Browse files Browse the repository at this point in the history
Check for nil pointer before dereferencing
  • Loading branch information
gabriel-samfira authored Mar 26, 2024
2 parents bb67ae5 + e2eb8f7 commit 18bb126
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/garm-cli/cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ var logCmd = &cobra.Command{
if err != nil {
var resp apiParams.APIErrorResponse
var msg string
if err := json.NewDecoder(response.Body).Decode(&resp); err == nil {
msg = resp.Details
var status string
if response != nil {
if response.Body != nil {
if err := json.NewDecoder(response.Body).Decode(&resp); err == nil {
msg = resp.Details
}
}
status = response.Status
}
log.Fatalf("failed to stream logs: %s (%s)", msg, response.Status)
log.Fatalf("failed to stream logs: %q %s (%s)", err, msg, status)
}
defer c.Close()

Expand Down

0 comments on commit 18bb126

Please sign in to comment.