From d6b851a1bd197fcf1f2d8183b6f86a92d5d8ee17 Mon Sep 17 00:00:00 2001 From: danilchap Date: Mon, 18 Apr 2016 10:54:04 -0700 Subject: [PATCH] Fixed memleak when two voip blocks present in single rtcp packet. BUG=chromium:603894 Review URL: https://codereview.webrtc.org/1901593002 Cr-Commit-Position: refs/heads/master@{#12413} --- webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.cc | 5 ++--- webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h | 3 ++- webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.cc index a5c0e28282..bfcc1bdfde 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.cc @@ -42,14 +42,13 @@ RTCPPacketInformation::RTCPPacketInformation() RTCPPacketInformation::~RTCPPacketInformation() { delete [] applicationData; - delete VoIPMetric; } void RTCPPacketInformation::AddVoIPMetric(const RTCPVoIPMetric* metric) { - VoIPMetric = new RTCPVoIPMetric(); - memcpy(VoIPMetric, metric, sizeof(RTCPVoIPMetric)); + VoIPMetric.reset(new RTCPVoIPMetric()); + memcpy(VoIPMetric.get(), metric, sizeof(RTCPVoIPMetric)); } void RTCPPacketInformation::AddApplicationData(const uint8_t* data, diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h index a792841962..da578c7ff9 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_help.h @@ -12,6 +12,7 @@ #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_RECEIVER_HELP_H_ #include +#include #include #include "webrtc/base/constructormagic.h" @@ -87,7 +88,7 @@ public: uint32_t xr_originator_ssrc; bool xr_dlrr_item; - RTCPVoIPMetric* VoIPMetric; + std::unique_ptr VoIPMetric; rtc::scoped_ptr transport_feedback_; diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc index 08f109bc29..96b5198ed3 100644 --- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc @@ -136,7 +136,7 @@ class RtcpReceiverTest : public ::testing::Test { rtcp_packet_info_.rtp_timestamp = rtcpPacketInformation.rtp_timestamp; rtcp_packet_info_.xr_dlrr_item = rtcpPacketInformation.xr_dlrr_item; if (rtcpPacketInformation.VoIPMetric) - rtcp_packet_info_.AddVoIPMetric(rtcpPacketInformation.VoIPMetric); + rtcp_packet_info_.AddVoIPMetric(rtcpPacketInformation.VoIPMetric.get()); rtcp_packet_info_.transport_feedback_.reset( rtcpPacketInformation.transport_feedback_.release()); return 0;