From 52088c9c0782529bd87d47db9e2f1b8474aebd0a Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 9 Dec 2017 17:21:04 +0300 Subject: [PATCH] Various fixes [#CLICKHOUSE-2] --- .../AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h | 2 ++ dbms/src/AggregateFunctions/AggregateFunctionTopK.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/dbms/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h b/dbms/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h index b7ab236bea1..70d692df0d3 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionGroupArrayInsertAt.h @@ -98,6 +98,8 @@ public: if (params.size() == 2) { length_to_resize = applyVisitor(FieldVisitorConvertToNumber(), params[1]); + if (length_to_resize > AGGREGATE_FUNCTION_GROUP_ARRAY_INSERT_AT_MAX_SIZE) + throw Exception("Too large array size", ErrorCodes::TOO_LARGE_ARRAY_SIZE); } } diff --git a/dbms/src/AggregateFunctions/AggregateFunctionTopK.h b/dbms/src/AggregateFunctions/AggregateFunctionTopK.h index fc741c7a981..d5755a82344 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionTopK.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionTopK.h @@ -72,6 +72,10 @@ public: throw Exception("Too large parameter for aggregate function " + getName() + ". Maximum: " + toString(TOP_K_MAX_SIZE), ErrorCodes::ARGUMENT_OUT_OF_BOUND); + if (k == 0) + throw Exception("Parameter 0 is illegal for aggregate function " + getName(), + ErrorCodes::ARGUMENT_OUT_OF_BOUND); + threshold = k; reserved = TOP_K_LOAD_FACTOR * k; }