Skip to content

Commit dc2d6ad

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sql/enumtype.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,14 @@ func (t enumType) Convert(v interface{}) (interface{}, error) {
188188
case uint64:
189189
return t.Convert(int(value))
190190
case float32:
191+
if value < float32(math.MinInt) || value > float32(math.MaxInt) {
192+
return nil, ErrConvertingToEnum.New(v)
193+
}
191194
return t.Convert(int(value))
192195
case float64:
196+
if value < float64(math.MinInt) || value > float64(math.MaxInt) {
197+
return nil, ErrConvertingToEnum.New(v)
198+
}
193199
return t.Convert(int(value))
194200
case decimal.Decimal:
195201
return t.Convert(value.IntPart())

0 commit comments

Comments
 (0)