Skip to content
Snippets Groups Projects
Commit 1ebbd65d authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #100016: cleanup crypto contexts in audio_srtp_session

parent 42b52b0c
Branches
Tags
No related merge requests found
...@@ -50,9 +50,11 @@ AudioRtpFactory::AudioRtpFactory(SIPCall *ca) : rtpSession_(NULL), ...@@ -50,9 +50,11 @@ AudioRtpFactory::AudioRtpFactory(SIPCall *ca) : rtpSession_(NULL),
AudioRtpFactory::~AudioRtpFactory() AudioRtpFactory::~AudioRtpFactory()
{ {
AudioSrtpSession* srtpSession = dynamic_cast<AudioSrtpSession*>(rtpSession_);
if (srtpSession)
srtpSession->deleteCryptoContexts();
delete rtpSession_; delete rtpSession_;
delete cachedLocalContext_;
delete cachedRemoteContext_;
} }
void AudioRtpFactory::initConfig() void AudioRtpFactory::initConfig()
......
...@@ -306,12 +306,23 @@ void AudioSrtpSession::initializeLocalCryptoContext() ...@@ -306,12 +306,23 @@ void AudioSrtpSession::initializeLocalCryptoContext()
void AudioSrtpSession::restoreCryptoContext(ost::CryptoContext *localContext, void AudioSrtpSession::restoreCryptoContext(ost::CryptoContext *localContext,
ost::CryptoContext *remoteContext) ost::CryptoContext *remoteContext)
{ {
if (remoteCryptoCtx_ != remoteContext) {
delete remoteCryptoCtx_; delete remoteCryptoCtx_;
remoteCryptoCtx_ = remoteContext; remoteCryptoCtx_ = remoteContext;
}
if (localCryptoCtx_ != localContext) {
delete localCryptoCtx_; delete localCryptoCtx_;
localCryptoCtx_ = localContext; localCryptoCtx_ = localContext;
}
setInQueueCryptoContext(remoteCryptoCtx_); setInQueueCryptoContext(remoteCryptoCtx_);
setOutQueueCryptoContext(localCryptoCtx_); setOutQueueCryptoContext(localCryptoCtx_);
} }
void AudioSrtpSession::deleteCryptoContexts()
{
delete remoteCryptoCtx_;
remoteCryptoCtx_ = 0;
delete localCryptoCtx_;
localCryptoCtx_ = 0;
}
} }
...@@ -101,6 +101,10 @@ class AudioSrtpSession : public AudioSymmetricRtpSession { ...@@ -101,6 +101,10 @@ class AudioSrtpSession : public AudioSymmetricRtpSession {
*/ */
void restoreCryptoContext(ost::CryptoContext *, ost::CryptoContext *); void restoreCryptoContext(ost::CryptoContext *, ost::CryptoContext *);
/**
* Force deletion of the current crypto contexts.
*/
void deleteCryptoContexts();
private: private:
NON_COPYABLE(AudioSrtpSession); NON_COPYABLE(AudioSrtpSession);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment