1
0
mirror of https://github.com/golang/go synced 2024-11-24 20:20:03 -07:00

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

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4081041
This commit is contained in:
Corey Thomasson 2011-01-19 09:55:46 -05:00 committed by Russ Cox
parent 4a7cdc7944
commit 43582bad33

View File

@ -18,7 +18,9 @@ var onceReadServices sync.Once
func readServices() {
services = make(map[string]map[string]int)
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() {
// "http 80/tcp www www-http # World Wide Web HTTP"
if i := byteIndex(line, '#'); i >= 0 {