]> Cypherpunks repositories - gostls13.git/commitdiff
strings: fix off-by-one error in test go1.3beta1
authorRui Ueyama <ruiu@google.com>
Tue, 22 Apr 2014 00:00:27 +0000 (17:00 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 22 Apr 2014 00:00:27 +0000 (17:00 -0700)
Previously it would panic because of out-of-bound access
if s1 is longer than s2.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/90110043

src/pkg/strings/strings_test.go

index 8347818d593df2b4bc6d5449fa852b043179c762..95a42019a3f0d46d93eec006449acf9fa4ce0d72 100644 (file)
@@ -652,7 +652,7 @@ func equal(m string, s1, s2 string, t *testing.T) bool {
        e1 := Split(s1, "")
        e2 := Split(s2, "")
        for i, c1 := range e1 {
-               if i > len(e2) {
+               if i >= len(e2) {
                        break
                }
                r1, _ := utf8.DecodeRuneInString(c1)