From 721f830cefa0c7bd44aa894de0701981b916cda0 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Tue, 9 Feb 2021 22:19:13 +0900 Subject: [PATCH] Fix error handling of decoding of slice type --- codec.go | 1 - decode_slice.go | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/codec.go b/codec.go index 031f12f..67cc9c3 100644 --- a/codec.go +++ b/codec.go @@ -71,7 +71,6 @@ func setupCodec() error { cachedOpcodeSets = make([]*opcodeSet, addrRange) existsCachedOpcodeSets = true cachedDecoder = make([]decoder, addrRange) - existsCachedDecoder = true baseTypeAddr = min maxTypeAddr = max return nil diff --git a/decode_slice.go b/decode_slice.go index 0005434..6c26b11 100644 --- a/decode_slice.go +++ b/decode_slice.go @@ -248,7 +248,12 @@ func (d *sliceDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int64 } cursor++ } + case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + return 0, d.errNumber([]byte{buf[cursor]}, cursor) + default: + goto ERROR } } +ERROR: return 0, errUnexpectedEndOfJSON("slice", cursor) }