Fixes #59172
Change-Id: I54d5e724f10117a40ec5dd58c810f6bbb2475933
GitHub-Last-Rev:
d1a986698c820415b2e0be12141091a3cbf6fde3
GitHub-Pull-Request: golang/go#59173
Reviewed-on: https://go-review.googlesource.com/c/go/+/478215
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
S []StringPair
}
+type LargeSliceString struct {
+ S []string
+}
+
func testEncodeDecode(t *testing.T, in, out any) {
t.Helper()
var b bytes.Buffer
rt := &LargeSliceStruct{}
testEncodeDecode(t, st, rt)
})
+ t.Run("string", func(t *testing.T) {
+ t.Parallel()
+ s := make([]string, 1<<21)
+ for i := range s {
+ s[i] = string(rune(i))
+ }
+ st := &LargeSliceString{S: s}
+ rt := &LargeSliceString{}
+ testEncodeDecode(t, st, rt)
+ })
}
if state.b.Len() == 0 {
errorf("decoding string array or slice: length exceeds input size (%d elements)", length)
}
+ if i >= len(slice) {
+ growSlice(v, &slice, length)
+ }
u := state.decodeUint()
n := int(u)
if n < 0 || uint64(n) != u || n > state.b.Len() {