From 599764ebb86727b46db089ee855326bd5485e366 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Fri, 13 Mar 2020 09:21:26 +0100 Subject: [PATCH] fix bug in Channel destructor for objects that were already moved --- include/amqpcpp/channel.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/amqpcpp/channel.h b/include/amqpcpp/channel.h index f30922a..ca2814c 100644 --- a/include/amqpcpp/channel.h +++ b/include/amqpcpp/channel.h @@ -22,7 +22,7 @@ class Channel private: /** * The implementation for the channel - * @var std::unique_ptr + * @var std::shared_ptr */ std::shared_ptr _implementation; @@ -58,7 +58,8 @@ public: virtual ~Channel() { // close the channel (this will eventually destruct the channel) - _implementation->close(); + // note that the channel may be in an invalid state in case it was moved, hence the "if" + if (_implementation) _implementation->close(); } /**