diff options
Diffstat (limited to 'vendor/github.com/bytedance/sonic/compat.go')
| -rw-r--r-- | vendor/github.com/bytedance/sonic/compat.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/vendor/github.com/bytedance/sonic/compat.go b/vendor/github.com/bytedance/sonic/compat.go index b694d7ce9..ec996493a 100644 --- a/vendor/github.com/bytedance/sonic/compat.go +++ b/vendor/github.com/bytedance/sonic/compat.go @@ -87,7 +87,17 @@ func (cfg frozenConfig) UnmarshalFromString(buf string, val interface{}) error { if cfg.DisallowUnknownFields { dec.DisallowUnknownFields() } - return dec.Decode(val) + err := dec.Decode(val) + if err != nil { + return err + } + + // check the trailing chars + offset := dec.InputOffset() + if t, err := dec.Token(); !(t == nil && err == io.EOF) { + return &json.SyntaxError{ Offset: offset} + } + return nil } // Unmarshal is implemented by sonic |
