Skip to content

Commit a440633

Browse files
authored
Merge pull request #23 from trimble-oss/alert-autofix-253
Potential fix for code scanning alert no. 253: Incorrect conversion between integer types
2 parents 0db5ff1 + 584a5b3 commit a440633

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sql/yeartype.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
package sql
1616

1717
import (
18+
"math"
1819
"reflect"
1920
"strconv"
2021
"time"
2122

22-
"github.com/shopspring/decimal"
23-
2423
"github.com/dolthub/vitess/go/sqltypes"
2524
"github.com/dolthub/vitess/go/vt/proto/query"
25+
"github.com/shopspring/decimal"
2626
"gopkg.in/src-d/go-errors.v1"
2727
)
2828

@@ -110,6 +110,9 @@ func (t yearType) Convert(v interface{}) (interface{}, error) {
110110
case float32:
111111
return t.Convert(int64(value))
112112
case float64:
113+
if value < float64(math.MinInt64) || value > float64(math.MaxInt64) {
114+
return nil, ErrConvertingToYear.New("float64 value out of bounds for int64")
115+
}
113116
return t.Convert(int64(value))
114117
case decimal.Decimal:
115118
return t.Convert(value.IntPart())

0 commit comments

Comments
 (0)