From cab12917457325ad8200bf23389ba6e80369f0f6 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Thu, 18 Dec 2014 06:58:42 +0000 Subject: [PATCH] Fixing the memory leak in AudioEncoderCopyRedDeathTest.NullSpeechEncoder Re-enable the test and explicitly call delete on red, even though the test should die in the AudioEncoderCopyRed cunstructor. Apparently, things work a little differently under memcheck. BUG=4108, 3926 R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/38419004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7942 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../codecs/red/audio_encoder_copy_red_unittest.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc index 92f748ce8..b26273479 100644 --- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc @@ -308,14 +308,14 @@ TEST_F(AudioEncoderCopyRedDeathTest, WrongFrameSize) { EXPECT_DEATH(Encode(), ""); } -// Test fails memcheck. -// https://code.google.com/p/webrtc/issues/detail?id=4108 -TEST_F(AudioEncoderCopyRedDeathTest, DISABLED_NullSpeechEncoder) { - AudioEncoderCopyRed* red; +TEST_F(AudioEncoderCopyRedDeathTest, NullSpeechEncoder) { + AudioEncoderCopyRed* red = NULL; AudioEncoderCopyRed::Config config; config.speech_encoder = NULL; EXPECT_DEATH(red = new AudioEncoderCopyRed(config), "Speech encoder not provided."); + // The delete operation is needed to avoid leak reports from memcheck. + delete red; } #endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)