Commit 43582bad authored by Corey Thomasson's avatar Corey Thomasson Committed by Russ Cox

net: avoid nil dereference if /etc/services can't be opened

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4081041
parent 4a7cdc79
...@@ -18,7 +18,9 @@ var onceReadServices sync.Once ...@@ -18,7 +18,9 @@ var onceReadServices sync.Once
func readServices() { func readServices() {
services = make(map[string]map[string]int) services = make(map[string]map[string]int)
var file *file var file *file
file, servicesError = open("/etc/services") if file, servicesError = open("/etc/services"); servicesError != nil {
return
}
for line, ok := file.readLine(); ok; line, ok = file.readLine() { for line, ok := file.readLine(); ok; line, ok = file.readLine() {
// "http 80/tcp www www-http # World Wide Web HTTP" // "http 80/tcp www www-http # World Wide Web HTTP"
if i := byteIndex(line, '#'); i >= 0 { if i := byteIndex(line, '#'); i >= 0 {
......
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