Skip to content

Commit 2a2b0b6

Browse files
jim-easterbrookkmilos
authored andcommitted
Set 'ok_' to false if timestamp overflow error
This is the correct way to indicate that the value conversion failed. (cherry picked from commit c7a0b78)
1 parent 0844f19 commit 2a2b0b6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/value.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ int64_t DateValue::toInt64(size_t /*n*/) const {
863863
uint32_t DateValue::toUint32(size_t /*n*/) const {
864864
const int64_t t = toInt64();
865865
if (t < 0 || t > std::numeric_limits<uint32_t>::max()) {
866+
ok_ = false;
866867
return 0;
867868
}
868869
return static_cast<uint32_t>(t);
@@ -875,6 +876,7 @@ float DateValue::toFloat(size_t n) const {
875876
Rational DateValue::toRational(size_t n) const {
876877
const int64_t t = toInt64(n);
877878
if (t < std::numeric_limits<int32_t>::min() || t > std::numeric_limits<int32_t>::max()) {
879+
ok_ = false;
878880
return {0, 1};
879881
}
880882
return {static_cast<int32_t>(t), 1};

0 commit comments

Comments
 (0)