Backend: Fix potential issue in txt.Int()
This commit is contained in:
parent
50d2ff1e69
commit
1fea0b136e
1 changed files with 1 additions and 8 deletions
|
@ -6,9 +6,6 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const MaxUint = ^uint(0)
|
||||
const MaxInt = int64(MaxUint >> 1)
|
||||
|
||||
var UnknownCountryCode = "zz"
|
||||
var CountryWordsRegexp = regexp.MustCompile("[\\p{L}]{2,}")
|
||||
|
||||
|
@ -18,16 +15,12 @@ func Int(s string) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
result, err := strconv.ParseInt(s, 10, 64)
|
||||
result, err := strconv.ParseInt(s, 10, 32)
|
||||
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
if result > MaxInt {
|
||||
return 0
|
||||
}
|
||||
|
||||
return int(result)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue