avoid using invalid iterator when erasing items using an iterator in a loop#436
Merged
avoid using invalid iterator when erasing items using an iterator in a loop#436
Conversation
Member
Author
dirk-thomas
reviewed
Feb 2, 2018
| for (auto it = guard_conditions_.begin(); it != guard_conditions_.end(); ++it) { | ||
| if (*it == guard_condition) { | ||
| guard_conditions_.erase(it); | ||
| it = guard_conditions_.erase(it); |
Member
There was a problem hiding this comment.
Why is this necessary? The next line breaks the loop and leaves the scope of it. I would consider the newly assigned it unused.
Member
Author
There was a problem hiding this comment.
That's a good point, I over matched it, I think I fixed it up correctly here: e0be1f6
| any_exec->callback_group = group; | ||
| any_exec->node_base = get_node_by_group(group, weak_nodes); | ||
| subscription_handles_.erase(it); | ||
| it = subscription_handles_.erase(it); |
| any_exec->callback_group = group; | ||
| any_exec->node_base = get_node_by_group(group, weak_nodes); | ||
| service_handles_.erase(it); | ||
| it = service_handles_.erase(it); |
| any_exec->callback_group = group; | ||
| any_exec->node_base = get_node_by_group(group, weak_nodes); | ||
| client_handles_.erase(it); | ||
| it = client_handles_.erase(it); |
dirk-thomas
approved these changes
Feb 2, 2018
Member
Author
13 tasks
nnmm
pushed a commit
to ApexAI/rclcpp
that referenced
this pull request
Jul 9, 2022
ros2#436) * Revert "Changes the default 3rd party logger from rcl_logging_noop to rcl_logging_log4cxx (ros2#425)" This reverts commit ac8ee90. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Revert "add explicit dependency on rcl_logging_log4cxx (ros2#435)" This reverts commit 816ce67. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org> * Add dependency on rcl_logging_noop. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Occurred when updating to
cppcheckto 1.82 on macOS.See: ros2/build_farmer#74 (comment)