This commit is contained in:
Kevin Wan
2024-01-14 09:37:01 +08:00
committed by GitHub
parent 408827d876
commit 44d347d48a
2 changed files with 28 additions and 13 deletions

View File

@@ -626,11 +626,11 @@ func (u *Unmarshaler) processFieldPrimitiveWithJSONNumber(fieldType reflect.Type
}
// 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()
derefedValue := value
for derefedValue.Type().Kind() == reflect.Ptr {
derefedValue = derefedValue.Elem()
}
if overflowValidator.OverflowFloat(fValue) {
if derefedValue.CanFloat() && derefedValue.OverflowFloat(fValue) {
return fmt.Errorf("parsing %q as float32: value out of range", v.String())
}