diff --git a/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp b/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp index 2b7b4b621d16157ab40771c1ef312808339175cb..d5f8bfa0b83afc5946f38c4a0ea8db78b7a83cde 100644 --- a/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp +++ b/sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp @@ -58,10 +58,25 @@ AudioSrtpSession::AudioSrtpSession (ManagerImpl * manager, SIPCall * sipcall) : _localMasterSaltLength (0), _remoteMasterKeyLength (0), _remoteMasterSaltLength (0), + _remoteCryptoCtx (NULL), + _localCryptoCtx (NULL), _remoteOfferIsSet (false) { } +AudioSrtpSession::~AudioSrtpSession() +{ + if (_remoteCryptoCtx) { + delete _remoteCryptoCtx; + _remoteCryptoCtx = NULL; + } + + if (_localCryptoCtx) { + delete _localCryptoCtx; + _localCryptoCtx = NULL; + } +} + void AudioSrtpSession::initLocalCryptoInfo() { _debug ("AudioSrtp: Set cryptographic info for this rtp session"); @@ -241,6 +256,11 @@ void AudioSrtpSession::initializeRemoteCryptoContext (void) CryptoSuiteDefinition crypto = sfl::CryptoSuites[_remoteCryptoSuite]; + if (_remoteCryptoCtx) { + delete _remoteCryptoCtx; + _remoteCryptoCtx = NULL; + } + _remoteCryptoCtx = new ost::CryptoContext (0x0, 0, // roc, 0L, // keydr, @@ -263,6 +283,11 @@ void AudioSrtpSession::initializeLocalCryptoContext (void) CryptoSuiteDefinition crypto = sfl::CryptoSuites[_localCryptoSuite]; + if (_localCryptoCtx) { + delete _localCryptoCtx; + _localCryptoCtx = NULL; + } + _localCryptoCtx = new ost::CryptoContext (OutgoingDataQueue::getLocalSSRC(), 0, // roc, 0L, // keydr, diff --git a/sflphone-common/src/audio/audiortp/AudioSrtpSession.h b/sflphone-common/src/audio/audiortp/AudioSrtpSession.h index 492da4f1fcf33c862144c35b3cfcb8d89f293219..281cff8d9cdd87e60925aec13a902716f3c071c2 100644 --- a/sflphone-common/src/audio/audiortp/AudioSrtpSession.h +++ b/sflphone-common/src/audio/audiortp/AudioSrtpSession.h @@ -83,6 +83,8 @@ class AudioSrtpSession : public ost::SymmetricRTPSession, public AudioRtpSession */ AudioSrtpSession (ManagerImpl * manager, SIPCall * sipcall); + ~AudioSrtpSession(); + /** * Used to get sdp crypto header to be included in sdp session. This * method must be called befor setRemoteCryptoInfo in case of an