From bc8704f44e5292de03447451333478ef61b323ef Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Wed, 11 Dec 2024 17:20:44 +0100 Subject: [PATCH] fix(Any): set pHolder to nullptr in destruct() --- Foundation/include/Poco/Any.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Foundation/include/Poco/Any.h b/Foundation/include/Poco/Any.h index e05d81f13..3a84c8b76 100644 --- a/Foundation/include/Poco/Any.h +++ b/Foundation/include/Poco/Any.h @@ -152,9 +152,16 @@ private: if (!isEmpty()) { if (!isLocal()) - delete pHolder; + { + auto* h { pHolder }; + pHolder = nullptr; + delete h; + } else - reinterpret_cast(holder)->~PlaceholderT(); + { + auto* h { reinterpret_cast(holder) }; + h->~PlaceholderT(); + } if (clear) std::memset(holder, 0, sizeof(holder)); }