- fix for out-of-bounds error found by rsc

- removed tests that may have wrong Go code from Makefile

R=r
OCL=15532
CL=15532
This commit is contained in:
Robert Griesemer 2008-09-19 10:56:35 -07:00
parent 5eb9e0621b
commit 26adb31c30
3 changed files with 2 additions and 4 deletions

View File

@ -21,7 +21,7 @@ func GetEnv(key string) string {
n := len(key);
for i := 0; i < sys.envc(); i++ {
v := sys.envv(i);
if v[0 : n] == key {
if n < len(v) && v[0 : n] == key && v[n] == '=' {
return v[n + 1 : len(v)]; // +1: trim "="
}
}

View File

@ -12,8 +12,6 @@ test: pretty
pretty *.go
pretty ../gosrc/*.go
pretty $(GOROOT)/test/sieve.go
pretty $(GOROOT)/test/bugs/*.go # some files legally don't compile
pretty $(GOROOT)/test/fixedbugs/*.go # some files legally don't compile
pretty $(GOROOT)/src/pkg/*.go
pretty $(GOROOT)/src/lib/flag.go
pretty $(GOROOT)/src/lib/fmt.go

View File

@ -21,7 +21,7 @@ func GetEnv(key string) string {
n := len(key);
for i := 0; i < sys.envc(); i++ {
v := sys.envv(i);
if v[0 : n] == key {
if n < len(v) && v[0 : n] == key && v[n] == '=' {
return v[n + 1 : len(v)]; // +1: trim "="
}
}