fix: issue 3840 (#3845)

This commit is contained in:
Kevin Wan
2024-01-13 23:48:50 +08:00
committed by GitHub
parent 9e33b557b1
commit 408827d876
3 changed files with 35 additions and 3 deletions

View File

@@ -625,7 +625,12 @@ func (u *Unmarshaler) processFieldPrimitiveWithJSONNumber(fieldType reflect.Type
return err
}
if value.OverflowFloat(fValue) {
// if value is a pointer, we need to check overflow with the pointer's value.
overflowValidator := value
if overflowValidator.Type().Kind() == reflect.Ptr {
overflowValidator = overflowValidator.Elem()
}
if overflowValidator.OverflowFloat(fValue) {
return fmt.Errorf("parsing %q as float32: value out of range", v.String())
}