Check for overflow before addition in anova function

This commit is contained in:
Antonio Andelic 2023-09-07 07:54:06 +00:00
parent 1b30f91e7a
commit c795b9c32f
3 changed files with 5 additions and 0 deletions

View File

@ -459,6 +459,10 @@ struct AnalysisOfVarianceMoments
void add(T value, size_t group)
{
if (group == std::numeric_limits<size_t>::max())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Too many groups for analysis of variance (should be no more than {}, got {})",
MAX_GROUPS_NUMBER, group);
resizeIfNeeded(group + 1);
xs1[group] += value;
xs2[group] += value * value;

View File

@ -0,0 +1 @@
SELECT analysisOfVariance(1, 18446744073709551615); -- { serverError BAD_ARGUMENTS }