Skip to content

Commit 72012c4

Browse files
Potential fix for code scanning alert no. 253: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 0db5ff1 commit 72012c4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sql/yeartype.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/dolthub/vitess/go/sqltypes"
2525
"github.com/dolthub/vitess/go/vt/proto/query"
2626
"gopkg.in/src-d/go-errors.v1"
27+
"math"
2728
)
2829

2930
var (
@@ -110,6 +111,9 @@ func (t yearType) Convert(v interface{}) (interface{}, error) {
110111
case float32:
111112
return t.Convert(int64(value))
112113
case float64:
114+
if value < float64(math.MinInt64) || value > float64(math.MaxInt64) {
115+
return nil, ErrConvertingToYear.New("float64 value out of bounds for int64")
116+
}
113117
return t.Convert(int64(value))
114118
case decimal.Decimal:
115119
return t.Convert(value.IntPart())

0 commit comments

Comments
 (0)