Merge pull request #294 from travisturner/overflow-fix

error on potential overflow
This commit is contained in:
Travis Turner 2020-04-15 16:24:37 -05:00 committed by GitHub
commit 0691b6c015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4596,6 +4596,9 @@ func getScaledInt(f *Field, v interface{}) (int64, error) {
if opt.Type == FieldTypeDecimal {
switch tv := v.(type) {
case uint64:
if tv > math.MaxInt64 {
return 0, errors.Errorf("uint64 value out of range for pql.Decimal: %d", tv)
}
dec := pql.NewDecimal(int64(tv), 0)
value = decimalToInt64(dec, opt)
case int64: