mirror of
https://github.com/golang/go
synced 2024-11-12 07:30:25 -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:
parent
4a7cdc7944
commit
43582bad33
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user