aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/gob/decode.go
diff options
context:
space:
mode:
authorAndy Pan <panjf2000@gmail.com>2023-08-18 13:39:57 +0800
committerGopher Robot <gobot@golang.org>2023-08-19 23:03:14 +0000
commitba626ac327f45a6d9d211fddd5b48e321fa0702a (patch)
treee19a50997936bcf46f8d85de099a39a40a8e48b3 /src/encoding/gob/decode.go
parent7b2f81eb3b19232c1d3a60241cb92c1c50d0e4ab (diff)
downloadgo-ba626ac327f45a6d9d211fddd5b48e321fa0702a.tar.xz
encoding/gob: prevent panic from index out of range in Decoder.typeString
I believe this bug is introduced by CL 460543 which optimizes the allocations by changing the type of `idToType` from map to slice, but didn't update the access code in `Decoder.typeString` that is safe for map but not for slice. Fixes #62117 Change-Id: I0f2e4cc2f34c54dada1f83458ba512a6fde6dcbe Reviewed-on: https://go-review.googlesource.com/c/go/+/520757 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/encoding/gob/decode.go')
-rw-r--r--src/encoding/gob/decode.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/encoding/gob/decode.go b/src/encoding/gob/decode.go
index 684505bf90..46657183f2 100644
--- a/src/encoding/gob/decode.go
+++ b/src/encoding/gob/decode.go
@@ -1082,7 +1082,7 @@ func (dec *Decoder) compatibleType(fr reflect.Type, fw typeId, inProgress map[re
func (dec *Decoder) typeString(remoteId typeId) string {
typeLock.Lock()
defer typeLock.Unlock()
- if t := idToType[remoteId]; t != nil {
+ if t := idToType(remoteId); t != nil {
// globally known type.
return t.string()
}