From 5ca90f55aeb5b75ccea9d1c51865920babe7a1a0 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 7 Aug 2018 16:01:42 +0200 Subject: [PATCH] Ensures that packets_lost is always positive. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a quick fix to ensure that we don't wrap the value. A proper solution would be to ensure that the packets_lost field is signed and handled as signed at all places it's used. Bug: webrtc:9598 Change-Id: I3622f2a61aa3af57db6292ef4c0a8e97c4833aa4 Reviewed-on: https://webrtc-review.googlesource.com/92881 Reviewed-by: Björn Terelius Reviewed-by: Magnus Flodman Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#24212} --- video/report_block_stats.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/video/report_block_stats.cc b/video/report_block_stats.cc index e11568eeaf..332709e37e 100644 --- a/video/report_block_stats.cc +++ b/video/report_block_stats.cc @@ -10,6 +10,8 @@ #include "video/report_block_stats.h" +#include + namespace webrtc { namespace { @@ -33,7 +35,8 @@ void ReportBlockStats::Store(const RtcpStatistics& rtcp_stats, uint32_t remote_ssrc, uint32_t source_ssrc) { RTCPReportBlock block; - block.packets_lost = rtcp_stats.packets_lost; + // TODO(srte): Remove this clamp when packets_lost is made signed. + block.packets_lost = std::max(0, rtcp_stats.packets_lost); block.fraction_lost = rtcp_stats.fraction_lost; block.extended_highest_sequence_number = rtcp_stats.extended_highest_sequence_number;