Skip to content

Commit

Permalink
Fix UB
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
  • Loading branch information
ivanpauno committed Mar 30, 2020
1 parent 0fa080e commit 47abe69
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rmw_fastrtps_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ rmw_create_node(
rmw_ret_t
rmw_destroy_node(rmw_node_t * node)
{
rmw_context_t * context = node->context;
rmw_ret_t ret = rmw_fastrtps_shared_cpp::__rmw_destroy_node(
eprosima_fastrtps_identifier, node);
if (RMW_RET_OK != ret) {
return ret;
}
return rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(node->context);
return rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(context);
}

rmw_ret_t
Expand Down
3 changes: 2 additions & 1 deletion rmw_fastrtps_dynamic_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ rmw_create_node(
rmw_ret_t
rmw_destroy_node(rmw_node_t * node)
{
rmw_context_t * context = node->context;
rmw_ret_t ret = rmw_fastrtps_shared_cpp::__rmw_destroy_node(
eprosima_fastrtps_identifier, node);
if (RMW_RET_OK != ret) {
return ret;
}
return rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(node->context);
return rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(context);
}

rmw_ret_t
Expand Down
2 changes: 1 addition & 1 deletion rmw_fastrtps_shared_cpp/src/init_rmw_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(rmw_context_t * contex
} else if (RMW_RET_OK != ret) {
RMW_SET_ERROR_MSG(error_string.str);
}
delete common_context;

common_context->graph_cache.clear_on_change_callback();
if (RMW_RET_OK != rmw_fastrtps_shared_cpp::__rmw_destroy_guard_condition(
Expand All @@ -100,6 +99,7 @@ rmw_fastrtps_shared_cpp::decrement_context_impl_ref_count(rmw_context_t * contex
"couldn't destroy graph_guard_condtion");
}

delete common_context;
context->impl->common = nullptr;
context->impl->participant_info = nullptr;
}
Expand Down

0 comments on commit 47abe69

Please sign in to comment.