Skip to content

Commit

Permalink
Merge pull request ros2#148 from ros2/check_node_validity
Browse files Browse the repository at this point in the history
ensure node is valid before using it
  • Loading branch information
dirk-thomas authored Jun 27, 2017
2 parents 9d37b9d + ee140b1 commit 7eecba9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions rcl/src/rcl/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,11 @@ rcl_client_fini(rcl_client_t * client, rcl_node_t * node)
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator());
if (client->impl) {
rcl_allocator_t allocator = client->impl->options.allocator;
rmw_ret_t ret =
rmw_destroy_client(rcl_node_get_rmw_handle(node), client->impl->rmw_handle);
rmw_node_t * rmw_node = rcl_node_get_rmw_handle(node);
if (!rmw_node) {
return RCL_RET_INVALID_ARGUMENT;
}
rmw_ret_t ret = rmw_destroy_client(rmw_node, client->impl->rmw_handle);
if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), allocator);
result = RCL_RET_ERROR;
Expand Down
6 changes: 5 additions & 1 deletion rcl/src/rcl/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,12 @@ rcl_publisher_fini(rcl_publisher_t * publisher, rcl_node_t * node)
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator());
if (publisher->impl) {
rcl_allocator_t allocator = publisher->impl->options.allocator;
rmw_node_t * rmw_node = rcl_node_get_rmw_handle(node);
if (!rmw_node) {
return RCL_RET_INVALID_ARGUMENT;
}
rmw_ret_t ret =
rmw_destroy_publisher(rcl_node_get_rmw_handle(node), publisher->impl->rmw_handle);
rmw_destroy_publisher(rmw_node, publisher->impl->rmw_handle);
if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), allocator);
result = RCL_RET_ERROR;
Expand Down
7 changes: 5 additions & 2 deletions rcl/src/rcl/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ rcl_service_fini(rcl_service_t * service, rcl_node_t * node)
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator());
if (service->impl) {
rcl_allocator_t allocator = service->impl->options.allocator;
rmw_ret_t ret =
rmw_destroy_service(rcl_node_get_rmw_handle(node), service->impl->rmw_handle);
rmw_node_t * rmw_node = rcl_node_get_rmw_handle(node);
if (!rmw_node) {
return RCL_RET_INVALID_ARGUMENT;
}
rmw_ret_t ret = rmw_destroy_service(rmw_node, service->impl->rmw_handle);
if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), allocator);
result = RCL_RET_ERROR;
Expand Down
6 changes: 5 additions & 1 deletion rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ rcl_subscription_fini(rcl_subscription_t * subscription, rcl_node_t * node)
RCL_CHECK_ARGUMENT_FOR_NULL(node, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator());
if (subscription->impl) {
rcl_allocator_t allocator = subscription->impl->options.allocator;
rmw_node_t * rmw_node = rcl_node_get_rmw_handle(node);
if (!rmw_node) {
return RCL_RET_INVALID_ARGUMENT;
}
rmw_ret_t ret =
rmw_destroy_subscription(rcl_node_get_rmw_handle(node), subscription->impl->rmw_handle);
rmw_destroy_subscription(rmw_node, subscription->impl->rmw_handle);
if (ret != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), allocator);
result = RCL_RET_ERROR;
Expand Down

0 comments on commit 7eecba9

Please sign in to comment.