mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Fix UBSan report in addMonths
This commit is contained in:
parent
6a7d873ea2
commit
3952a8e976
@ -1073,7 +1073,7 @@ public:
|
||||
{
|
||||
const Values & values = lut[toLUTIndex(v)];
|
||||
|
||||
Int64 month = static_cast<Int64>(values.month) + delta;
|
||||
Int64 month = values.month + static_cast<UInt64>(delta); /// Cast is to avoid UB in signed integer overflow.
|
||||
|
||||
if (month > 0)
|
||||
{
|
||||
|
@ -0,0 +1 @@
|
||||
0
|
2
tests/queries/0_stateless/01770_add_months_ubsan.sql
Normal file
2
tests/queries/0_stateless/01770_add_months_ubsan.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- Result does not make sense but UBSan report should not be triggered.
|
||||
SELECT ignore(now() + INTERVAL 9223372036854775807 MONTH);
|
Loading…
Reference in New Issue
Block a user