From 1f2cabaecdd2845f0225f0c39006377b00807862 Mon Sep 17 00:00:00 2001 From: "tina.legrand@webrtc.org" Date: Thu, 1 Mar 2012 08:46:09 +0000 Subject: [PATCH] Crash when deleting Celt. BUG=issue 6087770 TEST=audio_coding_module_test Review URL: https://webrtc-codereview.appspot.com/420001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1805 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/source/audio_coding_module_impl.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc index 18b6f4fb1f..39e390bfa7 100644 --- a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc +++ b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc @@ -182,17 +182,27 @@ AudioCodingModuleImpl::~AudioCodingModuleImpl() { if (_codecs[i] != NULL) { + // True stereo codecs share the same memory for master and + // slave, so slave codec need to be nullified here, since the + // memory will be deleted. + if(_slaveCodecs[i] == _codecs[i]) { + _slaveCodecs[i] = NULL; + } + + // Mirror index holds the address of the codec memory. assert(_mirrorCodecIdx[i] > -1); if(_codecs[_mirrorCodecIdx[i]] != NULL) { delete _codecs[_mirrorCodecIdx[i]]; _codecs[_mirrorCodecIdx[i]] = NULL; } + _codecs[i] = NULL; } if(_slaveCodecs[i] != NULL) { + // Delete memory for stereo usage of mono codecs. assert(_mirrorCodecIdx[i] > -1); if(_slaveCodecs[_mirrorCodecIdx[i]] != NULL) {