mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix segfault in combinator -Resample
This commit is contained in:
parent
f6cfb96748
commit
ee218c354e
@ -4,6 +4,7 @@
|
||||
#include <Columns/ColumnArray.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
#include <Common/assert_cast.h>
|
||||
#include <common/arithmeticOverflow.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -60,7 +61,18 @@ public:
|
||||
if (end < begin)
|
||||
total = 0;
|
||||
else
|
||||
total = (end - begin + step - 1) / step;
|
||||
{
|
||||
Key dif;
|
||||
size_t sum;
|
||||
if (common::subOverflow(end, begin, dif)
|
||||
|| common::addOverflow(static_cast<size_t>(dif), step, sum))
|
||||
{
|
||||
throw Exception("Overflow in internal computations in function " + getName()
|
||||
+ ". Too large arguments", ErrorCodes::ARGUMENT_OUT_OF_BOUND);
|
||||
}
|
||||
|
||||
total = (sum - 1) / step; // total = (end - begin + step - 1) / step
|
||||
}
|
||||
|
||||
if (total > MAX_ELEMENTS)
|
||||
throw Exception("The range given in function "
|
||||
|
1
tests/queries/0_stateless/01463_resample_overflow.sql
Normal file
1
tests/queries/0_stateless/01463_resample_overflow.sql
Normal file
@ -0,0 +1 @@
|
||||
select groupArrayResample(-9223372036854775808, 9223372036854775807, 9223372036854775807)(number, toInt64(number)) FROM numbers(7); -- { serverError 69 }
|
Loading…
Reference in New Issue
Block a user