From 56ec171fc08df2af2ef5d8783bfcad97bd8500b0 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 28 Dec 2019 08:08:22 +0300 Subject: [PATCH] Better check --- .../AggregateFunctionAggThrow.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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