Commit dd97923d authored by Michael Hoisie's avatar Michael Hoisie Committed by Russ Cox

net: fix segfault if /etc/hosts fails to open or doesn't exist

R=rsc
CC=golang-dev, r
https://golang.org/cl/194043
parent 5f4c052e
......@@ -30,7 +30,9 @@ func readHosts() {
if len(hosts.data) == 0 || hosts.time+cacheMaxAge <= now || hosts.path != hp {
hs := make(map[string][]string)
var file *file
file, _ = open(hp)
if file, _ = open(hp); file == nil {
return
}
for line, ok := file.readLine(); ok; line, ok = file.readLine() {
if i := byteIndex(line, '#'); i >= 0 {
// Discard comments.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment