From 022bd87ac1ccb4af98987b5ff6a3df9ca0ebc3e0 Mon Sep 17 00:00:00 2001 From: LAD Martin Date: Tue, 5 Nov 2019 13:39:45 +0000 Subject: [PATCH] Adds channel callbacks checking --- include/amqpcpp/channelimpl.h | 2 +- src/channelimpl.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/amqpcpp/channelimpl.h b/include/amqpcpp/channelimpl.h index a129fc3..c7c3ead 100644 --- a/include/amqpcpp/channelimpl.h +++ b/include/amqpcpp/channelimpl.h @@ -218,7 +218,7 @@ public: _readyCallback = callback; // direct call if channel is already ready - if (_state == state_ready) callback(); + if (_state == state_ready && callback) callback(); } /** diff --git a/src/channelimpl.cpp b/src/channelimpl.cpp index 3d9311f..60e6f7f 100644 --- a/src/channelimpl.cpp +++ b/src/channelimpl.cpp @@ -73,7 +73,10 @@ void ChannelImpl::onError(const ErrorCallback &callback) // if the channel is usable, all is ok if (usable()) return; - + + // validity check + if (!callback) return; + // is the channel closing down? if (_state == state_closing) return callback("Channel is closing down");