File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -610,16 +610,18 @@ Executor::execute_subscription(rclcpp::SubscriptionBase::SharedPtr subscription)
610610 return true ;
611611 },
612612 [&]() {subscription->handle_loaned_message (loaned_msg, message_info);});
613- rcl_ret_t ret = rcl_return_loaned_message_from_subscription (
614- subscription->get_subscription_handle ().get (),
615- loaned_msg);
616- if (RCL_RET_OK != ret) {
617- RCLCPP_ERROR (
618- rclcpp::get_logger (" rclcpp" ),
619- " rcl_return_loaned_message_from_subscription() failed for subscription on topic '%s': %s" ,
620- subscription->get_topic_name (), rcl_get_error_string ().str );
613+ if (nullptr != loaned_msg) {
614+ rcl_ret_t ret = rcl_return_loaned_message_from_subscription (
615+ subscription->get_subscription_handle ().get (),
616+ loaned_msg);
617+ if (RCL_RET_OK != ret) {
618+ RCLCPP_ERROR (
619+ rclcpp::get_logger (" rclcpp" ),
620+ " rcl_return_loaned_message_from_subscription() failed for subscription on topic '%s': %s" ,
621+ subscription->get_topic_name (), rcl_get_error_string ().str );
622+ }
623+ loaned_msg = nullptr ;
621624 }
622- loaned_msg = nullptr ;
623625 } else {
624626 // This case is taking a copy of the message data from the middleware via
625627 // inter-process communication.
You can’t perform that action at this time.
0 commit comments