-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid using invalid iterator when erasing items using an iterator in a loop #436
Conversation
@@ -78,7 +78,7 @@ class AllocatorMemoryStrategy : public memory_strategy::MemoryStrategy | |||
{ | |||
for (auto it = guard_conditions_.begin(); it != guard_conditions_.end(); ++it) { | |||
if (*it == guard_condition) { | |||
guard_conditions_.erase(it); | |||
it = guard_conditions_.erase(it); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? The next line breaks the loop and leaves the scope of it
. I would consider the newly assigned it
unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, I over matched it, I think I fixed it up correctly here: e0be1f6
@@ -266,11 +266,11 @@ class AllocatorMemoryStrategy : public memory_strategy::MemoryStrategy | |||
} | |||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
@@ -301,11 +301,11 @@ class AllocatorMemoryStrategy : public memory_strategy::MemoryStrategy | |||
any_exec->service = service; | |||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
@@ -334,11 +334,11 @@ class AllocatorMemoryStrategy : public memory_strategy::MemoryStrategy | |||
any_exec->client = client; | |||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
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 <[email protected]> * Revert "add explicit dependency on rcl_logging_log4cxx (ros2#435)" This reverts commit 816ce67. Signed-off-by: Chris Lalancette <[email protected]> * Add dependency on rcl_logging_noop. Signed-off-by: Chris Lalancette <[email protected]>
Occurred when updating to
cppcheck
to 1.82 on macOS.See: ros2/build_farmer#74 (comment)