diff --git a/dbms/src/AggregateFunctions/AggregateFunctionAggThrow.cpp b/dbms/src/AggregateFunctions/AggregateFunctionAggThrow.cpp index 4e9f10a3783..ebaa146dbd8 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionAggThrow.cpp +++ b/dbms/src/AggregateFunctions/AggregateFunctionAggThrow.cpp @@ -23,11 +23,22 @@ namespace struct AggregateFunctionThrowData { - std::unique_ptr memory{ new char }; + bool allocated; + + AggregateFunctionThrowData() : allocated(true) {} + ~AggregateFunctionThrowData() + { + volatile bool * allocated_ptr = &allocated; + + if (*allocated_ptr) + *allocated_ptr = false; + else + abort(); + } }; /** Throw on creation with probability specified in parameter. - * Allocates some memory in constructor and deallocates in desctructor. + * It will check correct destruction of the state. * This is intended to check for exception safety. */ class AggregateFunctionThrow final : public IAggregateFunctionDataHelper