From 1a4cf30047ef214acc895915c68a3942505f1502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20de=20Vicente=20Pe=C3=B1a?= Date: Tue, 22 Aug 2023 16:31:13 +0200 Subject: [PATCH] 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 Reviewed-by: Gustaf Ullberg Cr-Commit-Position: refs/heads/main@{#40605} --- modules/audio_processing/aec3/matched_filter_lag_aggregator.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc index 8eb27c3a3f..c8ac417a8b 100644 --- a/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc +++ b/modules/audio_processing/aec3/matched_filter_lag_aggregator.cc @@ -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(kMatchedFilterWindowSizeSubBlocks); it = it + kMatchedFilterWindowSizeSubBlocks) { auto it_max_element = std::max_element(it, it + kMatchedFilterWindowSizeSubBlocks);