Avoiding to increase an iterator when the result can be larger than their container end.

Bug: webrtc:15438
Change-Id: I0d75436bc845590c76466bde7007e921f842a9d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/317320
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40605}
This commit is contained in:
Jesús de Vicente Peña 2023-08-22 16:31:13 +02:00 committed by WebRTC LUCI CQ
parent 45ccf63c0f
commit 1a4cf30047

View File

@ -162,7 +162,8 @@ void MatchedFilterLagAggregator::PreEchoLagAggregator::Aggregate(
float penalization_per_delay = 1.0f;
float max_histogram_value = -1.0f;
for (auto it = histogram_.begin();
it + kMatchedFilterWindowSizeSubBlocks <= histogram_.end();
std::distance(it, histogram_.end()) >=
static_cast<int>(kMatchedFilterWindowSizeSubBlocks);
it = it + kMatchedFilterWindowSizeSubBlocks) {
auto it_max_element =
std::max_element(it, it + kMatchedFilterWindowSizeSubBlocks);