fix segfault in combinator -Resample

This commit is contained in:
Anton Popov 2020-09-08 02:18:07 +03:00
parent f6cfb96748
commit ee218c354e
3 changed files with 14 additions and 1 deletions

View File

@ -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 "

View File

@ -0,0 +1 @@
select groupArrayResample(-9223372036854775808, 9223372036854775807, 9223372036854775807)(number, toInt64(number)) FROM numbers(7); -- { serverError 69 }