Backend: Fix potential issue in txt.Int()

This commit is contained in:
Michael Mayer 2021-05-04 17:54:57 +02:00
parent 50d2ff1e69
commit 1fea0b136e

View file

@ -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)
}