Skip to content

Commit 883f390

Browse files
authored
Merge pull request #25 from trimble-oss/alert-autofix-197
Potential fix for code scanning alert no. 197: Incorrect conversion between integer types
2 parents d6fd497 + 5e6ddc5 commit 883f390

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sql/system_booltype.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package sql
1616

1717
import (
18+
"math"
1819
"reflect"
1920
"strconv"
2021
"strings"
@@ -98,7 +99,10 @@ func (t systemBoolType) Convert(v interface{}) (interface{}, error) {
9899
// Float values aren't truly accepted, but the engine will give them when it should give ints.
99100
// Therefore, if the float doesn't have a fractional portion, we treat it as an int.
100101
if value == float64(int64(value)) {
101-
return t.Convert(int64(value))
102+
if value >= float64(math.MinInt64) && value <= float64(math.MaxInt64) {
103+
return t.Convert(int64(value))
104+
}
105+
return nil, ErrInvalidSystemVariableValue.New(t.varName, v)
102106
}
103107
case decimal.Decimal:
104108
f, _ := value.Float64()

0 commit comments

Comments
 (0)