Skip to content

Commit

Permalink
resolve null pointer ref when splunk HEC isn't responding before the …
Browse files Browse the repository at this point in the history
…timeout
  • Loading branch information
aetaric committed Oct 7, 2023
1 parent e6e3d6d commit b514e34
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions features/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ func (s *Stats) Write(field string, count uint64) {
if err != nil {
log.Warn(err)
}
if resp.StatusCode != 200 {
if resp != nil && resp.StatusCode != 200 {
log.Warnf("Recieved %d status code from Splunk", resp.StatusCode)
defer resp.Body.Close()
}
defer resp.Body.Close()
}(splunkstats)
}
// Update stats DB
Expand Down
4 changes: 2 additions & 2 deletions notifications/splunkhec.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ func (d SplunkHEC) Notify(title string, description string, notifType string, pa
if err != nil {
log.Warn(err)
}
if resp.StatusCode != 200 {
if resp != nil && resp.StatusCode != 200 {
log.Warnf("Recieved %d status code from Splunk", resp.StatusCode)
defer resp.Body.Close()
}
defer resp.Body.Close()
}(splunkevent)
return true
}
Expand Down

0 comments on commit b514e34

Please sign in to comment.