Skip to content

Commit

Permalink
Ensures that packets_lost is always positive.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Magnus Flodman <[email protected]>
Commit-Queue: Sebastian Jansson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#24212}
  • Loading branch information
jonex authored and Commit Bot committed Aug 7, 2018
1 parent f0d5fc9 commit 5ca90f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion video/report_block_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "video/report_block_stats.h"

#include <algorithm>

namespace webrtc {

namespace {
Expand All @@ -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;
Expand Down

0 comments on commit 5ca90f5

Please sign in to comment.