select: Fix integer conversion overflow (#10437)

Do not convert float value to integer if it will over/underflow.

The comparison cannot be `<=` since rounding may overflow it.

Fixes #10436
This commit is contained in:
Klaus Post
2020-09-08 15:56:11 -07:00
committed by GitHub
parent 6a0372be6c
commit 0987069e37
2 changed files with 22 additions and 3 deletions

View File

@@ -309,7 +309,7 @@ func (v Value) CSVString() string {
// floatToValue converts a float into int representation if needed.
func floatToValue(f float64) *Value {
intPart, fracPart := math.Modf(f)
if fracPart == 0 {
if fracPart == 0 && intPart < math.MaxInt64 && intPart > math.MinInt64 {
return FromInt(int64(intPart))
}
return FromFloat(f)