Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit be14811

Browse files
committed
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 <[email protected]> Reviewed-by: Sebastian Jansson <[email protected]> Reviewed-by: Karl Wiberg <[email protected]> Cr-Commit-Position: refs/heads/master@{#31354}
1 parent 7c298ef commit be14811

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rtc_base/thread.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ void ThreadManager::RegisterSendAndCheckForCycles(Thread* source,
168168
// We check the pre-existing who-sends-to-who graph for any path from target
169169
// to source. This loop is guaranteed to terminate because per the send graph
170170
// invariant, there are no cycles in the graph.
171-
for (auto it = all_targets.begin(); it != all_targets.end(); ++it) {
172-
const auto& targets = send_graph_[*it];
171+
for (size_t i = 0; i < all_targets.size(); i++) {
172+
const auto& targets = send_graph_[all_targets[i]];
173173
all_targets.insert(all_targets.end(), targets.begin(), targets.end());
174174
}
175175
RTC_CHECK_EQ(absl::c_count(all_targets, source), 0)

0 commit comments

Comments
 (0)