Merge pull request #22099 from ClickHouse/map-populate-series-ubsan

Fix UBSan report in mapPopulateSeries.
This commit is contained in:
alexey-milovidov 2021-03-25 16:00:21 +03:00 committed by GitHub
commit cb6926629e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -190,7 +190,7 @@ private:
}
static constexpr size_t MAX_ARRAY_SIZE = 1ULL << 30;
if (static_cast<size_t>(max_key - min_key) > MAX_ARRAY_SIZE)
if (static_cast<size_t>(max_key) - static_cast<size_t>(min_key) > MAX_ARRAY_SIZE)
throw Exception(ErrorCodes::TOO_LARGE_ARRAY_SIZE, "Too large array size in the result of function {}", getName());
/* fill the result arrays */

View File

@ -0,0 +1,2 @@
-- Should correctly throw exception about overflow:
SELECT mapPopulateSeries([-9223372036854775808, toUInt32(2)], [toUInt32(1023), -1]); -- { serverError 128 }