From 3227ed567b434405a770e0e0b4e5501255717bf1 Mon Sep 17 00:00:00 2001 From: "hellner@google.com" Date: Thu, 25 Aug 2011 15:34:19 +0000 Subject: [PATCH] Fixed potential memory leak in unit test and removed an unnecessary copy. Review URL: http://webrtc-codereview.appspot.com/131001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@447 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../talk/app/webrtc/webrtcsession_unittest.cc | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc index 3ab92f48ba..a8f17b9a86 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/webrtcsession_unittest.cc @@ -369,21 +369,10 @@ class WebRtcSessionTest : public OnSignalImpl { return true; } - bool CallOnRemoteDescription(cricket::SessionDescription* session_shallow, - std::vector* candidates_shallow) { - std::vector candidates; - candidates.insert(candidates.end(), candidates_shallow->begin(), - candidates_shallow->end()); - if (candidates.empty()) { - return false; - } - cricket::SessionDescription* description = CopySessionDescription( - session_shallow); - if (description == NULL) { - return false; - } + bool CallOnRemoteDescription( + cricket::SessionDescription* description, + std::vector candidates) { if (!session_->OnRemoteDescription(description, candidates)) { - delete description; return false; } return true; @@ -524,7 +513,10 @@ TEST(WebRtcSessionTest, AudioSendReceiveCallSetUp) { &candidates); ASSERT_FALSE(candidates.empty()); ASSERT_FALSE(local_session == NULL); - ASSERT_TRUE(my_session->CallOnRemoteDescription(local_session, &candidates)); + if (!my_session->CallOnRemoteDescription(local_session, candidates)) { + delete local_session; + FAIL(); + } // All callbacks should be caught by my session. Assert it. ASSERT_FALSE(CallbackReceived(my_session.get(), 1000)); @@ -546,7 +538,11 @@ TEST(WebRtcSessionTest, VideoSendCallSetUp) { &candidates); ASSERT_FALSE(candidates.empty()); ASSERT_FALSE(local_session == NULL); - ASSERT_TRUE(my_session->CallOnRemoteDescription(local_session, &candidates)); + + if (!my_session->CallOnRemoteDescription(local_session, candidates)) { + delete local_session; + FAIL(); + } // All callbacks should be caught by my session. Assert it. ASSERT_FALSE(CallbackReceived(my_session.get(), 1000));