提交 badd5165 编写于 作者: A Alexey Milovidov

Fix UBSan report in rounding to years intervals

上级 eaeb4a3b
......@@ -807,7 +807,14 @@ public:
return toFirstDayNumOfYear(v);
const LUTIndex i = toLUTIndex(v);
return toDayNum(years_lut[lut[i].year / years * years - DATE_LUT_MIN_YEAR]);
UInt16 year = lut[i].year / years * years;
/// For example, rounding down 1925 to 100 years will be 1900, but it's less than min supported year.
if (unlikely(year < DATE_LUT_MIN_YEAR))
year = DATE_LUT_MIN_YEAR;
return toDayNum(years_lut[year - DATE_LUT_MIN_YEAR]);
}
inline ExtendedDayNum toStartOfQuarterInterval(ExtendedDayNum d, UInt64 quarters) const
......
SELECT toStartOfInterval(toDateTime(-9223372036854775808), toIntervalYear(100), 'Europe/Moscow') FORMAT Null;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册