Merge pull request #309 from LadMartin/bugfix/Channel-Unchecked-Callbacks

Adds channel callbacks checking
This commit is contained in:
Emiel Bruijntjes 2019-11-06 08:38:42 +01:00 committed by GitHub
commit 77a0c99d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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();
}
/**

View File

@ -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");