mirror of
https://github.com/btcsuite/btcd.git
synced 2025-02-22 06:21:50 +01:00
btcjson: check if both begin and end are numbers in UnmarshalJSON
This commit is contained in:
parent
029e5a3cb5
commit
1a1dd2a2b3
1 changed files with 7 additions and 2 deletions
|
@ -903,9 +903,14 @@ func (r *DescriptorRange) UnmarshalJSON(data []byte) error {
|
|||
if len(v) != 2 {
|
||||
return fmt.Errorf("expected [begin,end] integer range, got: %v", unmarshalled)
|
||||
}
|
||||
begin, ok1 := v[0].(float64)
|
||||
end, ok2 := v[1].(float64)
|
||||
if !ok1 || !ok2 {
|
||||
return fmt.Errorf("expected both begin and end to be numbers, got: %v", v)
|
||||
}
|
||||
r.Value = []int{
|
||||
int(v[0].(float64)),
|
||||
int(v[1].(float64)),
|
||||
int(begin),
|
||||
int(end),
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("invalid descriptor range value: %v", unmarshalled)
|
||||
|
|
Loading…
Add table
Reference in a new issue