diff options
Diffstat (limited to 'src/encoding/json/decode.go')
| -rw-r--r-- | src/encoding/json/decode.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go index 360fc69d04..407fbcedbe 100644 --- a/src/encoding/json/decode.go +++ b/src/encoding/json/decode.go @@ -949,6 +949,9 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool } v.SetBytes(b[:n]) case reflect.String: + if v.Type() == numberType && !isValidNumber(string(s)) { + return fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", item) + } v.SetString(string(s)) case reflect.Interface: if v.NumMethod() == 0 { |
