Skip to content

Commit

Permalink
fix segfault on gcp metadata server check (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksawarzynski authored Jul 21, 2024
1 parent 8eec094 commit cce7e31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ var style aurora.Aurora

func IsRunningInGCP() bool {
resp, err := http.Get("http://metadata.google.internal")
resp.Body.Close()

if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}

return err == nil
}

Expand Down

0 comments on commit cce7e31

Please sign in to comment.