mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Merge pull request #14 from roseteromeo56/alert-autofix-8
Potential fix for code scanning alert no. 8: Incorrect conversion between integer types
This commit is contained in:
commit
28d0d3ffab
1 changed files with 8 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -58,8 +59,14 @@ func (b *Long) UnmarshalGraphQL(input interface{}) error {
|
||||||
if strings.HasPrefix(input, "0x") {
|
if strings.HasPrefix(input, "0x") {
|
||||||
// apply leniency and support hex representations of longs.
|
// apply leniency and support hex representations of longs.
|
||||||
value, err := hexutil.DecodeUint64(input)
|
value, err := hexutil.DecodeUint64(input)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if value > math.MaxInt64 {
|
||||||
|
return fmt.Errorf("value %d exceeds int64 range", value)
|
||||||
|
}
|
||||||
*b = Long(value)
|
*b = Long(value)
|
||||||
return err
|
return nil
|
||||||
} else {
|
} else {
|
||||||
value, err := strconv.ParseInt(input, 10, 64)
|
value, err := strconv.ParseInt(input, 10, 64)
|
||||||
*b = Long(value)
|
*b = Long(value)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue