mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00
Fix an incorrect use of iterator.
This change uses index instead of iterator to access elements in `all_targets` to avoid using invalidated iterator after insertion. MSVC 2019 reports "cannot increment value-initialized deque iterator". And C++ standard says "an insertion at either end of the deque invalidates all the iterators to the deque". Bug: webrtc:11255 Change-Id: I2167bfe875bb0059e81eba334bbd6921e287d6d9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176101 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31354}
This commit is contained in:
parent
cdbebb086e
commit
c33eeab2ca
1 changed files with 2 additions and 2 deletions
|
@ -168,8 +168,8 @@ void ThreadManager::RegisterSendAndCheckForCycles(Thread* source,
|
||||||
// We check the pre-existing who-sends-to-who graph for any path from target
|
// We check the pre-existing who-sends-to-who graph for any path from target
|
||||||
// to source. This loop is guaranteed to terminate because per the send graph
|
// to source. This loop is guaranteed to terminate because per the send graph
|
||||||
// invariant, there are no cycles in the graph.
|
// invariant, there are no cycles in the graph.
|
||||||
for (auto it = all_targets.begin(); it != all_targets.end(); ++it) {
|
for (size_t i = 0; i < all_targets.size(); i++) {
|
||||||
const auto& targets = send_graph_[*it];
|
const auto& targets = send_graph_[all_targets[i]];
|
||||||
all_targets.insert(all_targets.end(), targets.begin(), targets.end());
|
all_targets.insert(all_targets.end(), targets.begin(), targets.end());
|
||||||
}
|
}
|
||||||
RTC_CHECK_EQ(absl::c_count(all_targets, source), 0)
|
RTC_CHECK_EQ(absl::c_count(all_targets, source), 0)
|
||||||
|
|
Loading…
Reference in a new issue