diff --git a/src/value.cpp b/src/value.cpp index b2ca8b7c9b..378072f69c 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -863,6 +863,7 @@ int64_t DateValue::toInt64(size_t /*n*/) const { uint32_t DateValue::toUint32(size_t /*n*/) const { const int64_t t = toInt64(); if (t < 0 || t > std::numeric_limits::max()) { + ok_ = false; return 0; } return static_cast(t); @@ -873,7 +874,12 @@ float DateValue::toFloat(size_t n) const { } Rational DateValue::toRational(size_t n) const { - return {static_cast(toInt64(n)), 1}; + const int64_t t = toInt64(n); + if (t < std::numeric_limits::min() || t > std::numeric_limits::max()) { + ok_ = false; + return {0, 1}; + } + return {static_cast(t), 1}; } TimeValue::TimeValue() : Value(time) {