Skip to content

Commit baf004d

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

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sql/yeartype.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ func (t yearType) Convert(v interface{}) (interface{}, error) {
111111
}
112112
return t.Convert(int64(value))
113113
case float32:
114+
if float64(value) < float64(math.MinInt64) || float64(value) > float64(math.MaxInt64) {
115+
return nil, ErrConvertingToYear.New("float32 value out of bounds for int64")
116+
}
117+
// Check for fractional part
118+
if float64(value) != math.Trunc(float64(value)) {
119+
return nil, ErrConvertingToYear.New("float32 value has a fractional component, cannot convert to int64")
120+
}
114121
return t.Convert(int64(value))
115122
case float64:
116123
if value < float64(math.MinInt16) || value > float64(math.MaxInt16) {

0 commit comments

Comments
 (0)