mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Potential fix for code scanning alert no. 8: Incorrect conversion between integer types
Romeo Rosete Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
parent
58818e1660
commit
21540df1d8
1 changed files with 8 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
|
@ -58,8 +59,14 @@ func (b *Long) UnmarshalGraphQL(input interface{}) error {
|
|||
if strings.HasPrefix(input, "0x") {
|
||||
// apply leniency and support hex representations of longs.
|
||||
value, err := hexutil.DecodeUint64(input)
|
||||
*b = Long(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if value > math.MaxInt64 {
|
||||
return fmt.Errorf("value %d exceeds int64 range", value)
|
||||
}
|
||||
*b = Long(value)
|
||||
return nil
|
||||
} else {
|
||||
value, err := strconv.ParseInt(input, 10, 64)
|
||||
*b = Long(value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue