Skip to content

Commit

Permalink
Bugfix: Readme example sigsegv
Browse files Browse the repository at this point in the history
When the requested server is completely non-responsive, and err!=nil,
res will be nil. The references to StatusCode and Body.Close() will
cause a SIGSEGV. If err!=nil, don’t reference res.
  • Loading branch information
Adam Brakhane committed Feb 11, 2017
1 parent 9daaf8a commit 99ec970
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@ func pinger(ch chan string, site string) {

if err != nil {
ch <- "-" + site
}


if res.StatusCode != 200 {
ch <- "-" + site
} else {
ch <- "+" + site
if res.StatusCode != 200 {
ch <- "-" + site
} else {
ch <- "+" + site
}
res.Body.Close()
}

res.Body.Close()
time.Sleep(30 * time.Second)
}
}
Expand Down

0 comments on commit 99ec970

Please sign in to comment.