common/math: fix flaw in HexOrDecimal64

This commit is contained in:
Martin Holst Swende 2024-06-17 20:18:23 +02:00
parent 0c9b7dc634
commit fe49856ea7
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -46,7 +46,7 @@ type HexOrDecimal64 uint64
// It is similar to UnmarshalText, but allows parsing real decimals too, not just // It is similar to UnmarshalText, but allows parsing real decimals too, not just
// quoted decimal strings. // quoted decimal strings.
func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error { func (i *HexOrDecimal64) UnmarshalJSON(input []byte) error {
if len(input) > 0 && input[0] == '"' { if len(input) > 1 && input[0] == '"' {
input = input[1 : len(input)-1] input = input[1 : len(input)-1]
} }
return i.UnmarshalText(input) return i.UnmarshalText(input)