Fix UBSan report in GatherUtils

This commit is contained in:
Alexey Milovidov 2021-01-31 10:10:37 +03:00
parent d93dad0ec3
commit 248540e58f
3 changed files with 3 additions and 2 deletions

View File

@ -711,7 +711,7 @@ void resizeDynamicSize(ArraySource && array_source, ValueSource && value_source,
}
else
{
auto length = static_cast<size_t>(-size);
auto length = -static_cast<size_t>(size);
if (length > MAX_ARRAY_SIZE)
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Too large array size: {}, maximum: {}",
length, MAX_ARRAY_SIZE);
@ -760,7 +760,7 @@ void resizeConstantSize(ArraySource && array_source, ValueSource && value_source
}
else
{
auto length = static_cast<size_t>(-size);
auto length = -static_cast<size_t>(size);
if (length > MAX_ARRAY_SIZE)
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Too large array size: {}, maximum: {}",
length, MAX_ARRAY_SIZE);

View File

@ -0,0 +1 @@
SELECT arrayResize([1, 2, 3], -9223372036854775808); -- { serverError 128 }