From 010c47e519ed3274399051b419ff6550f58d5488 Mon Sep 17 00:00:00 2001 From: Barry Xu Date: Sat, 10 Jan 2026 22:35:59 +0800 Subject: [PATCH 1/2] Improve the robustness of the TopicEndpointInfo constructor (#3013) * Improve the robustness of the TopicEndpointInfo constructor Signed-off-by: Barry Xu * Improve TopicEndpointInfo constructor to validate input parameters Signed-off-by: Barry Xu --------- Signed-off-by: Barry Xu (cherry picked from commit 7f783cbf587a2897572263b48b9583d8021f3958) # Conflicts: # rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp --- .../rclcpp/node_interfaces/node_graph_interface.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp b/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp index fefda0da69..41fd2345a7 100644 --- a/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp +++ b/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp @@ -53,12 +53,25 @@ class TopicEndpointInfo /// Construct a TopicEndpointInfo from a rcl_topic_endpoint_info_t. RCLCPP_PUBLIC explicit TopicEndpointInfo(const rcl_topic_endpoint_info_t & info) +<<<<<<< HEAD : node_name_(info.node_name), node_namespace_(info.node_namespace), topic_type_(info.topic_type), endpoint_type_(static_cast(info.endpoint_type)), qos_profile_({info.qos_profile.history, info.qos_profile.depth}, info.qos_profile) +======= + : endpoint_type_(static_cast(info.endpoint_type)), + qos_profile_({info.qos_profile.history, info.qos_profile.depth}, info.qos_profile), + topic_type_hash_(info.topic_type_hash) +>>>>>>> 7f783cb (Improve the robustness of the TopicEndpointInfo constructor (#3013)) { + if (!info.node_name || !info.node_namespace || !info.topic_type) { + throw std::invalid_argument("Constructor TopicEndpointInfo with invalid topic endpoint info"); + } + node_name_ = info.node_name; + node_namespace_ = info.node_namespace; + topic_type_ = info.topic_type; + std::copy(info.endpoint_gid, info.endpoint_gid + RMW_GID_STORAGE_SIZE, endpoint_gid_.begin()); } From 321d8ba23cfb68363274eefe6d29d4abab50226b Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Cordero Date: Mon, 12 Jan 2026 09:54:29 +0100 Subject: [PATCH 2/2] Fixed merge Signed-off-by: Alejandro Hernandez Cordero --- .../rclcpp/node_interfaces/node_graph_interface.hpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp b/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp index 41fd2345a7..1eba5779d7 100644 --- a/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp +++ b/rclcpp/include/rclcpp/node_interfaces/node_graph_interface.hpp @@ -53,17 +53,8 @@ class TopicEndpointInfo /// Construct a TopicEndpointInfo from a rcl_topic_endpoint_info_t. RCLCPP_PUBLIC explicit TopicEndpointInfo(const rcl_topic_endpoint_info_t & info) -<<<<<<< HEAD - : node_name_(info.node_name), - node_namespace_(info.node_namespace), - topic_type_(info.topic_type), - endpoint_type_(static_cast(info.endpoint_type)), - qos_profile_({info.qos_profile.history, info.qos_profile.depth}, info.qos_profile) -======= : endpoint_type_(static_cast(info.endpoint_type)), - qos_profile_({info.qos_profile.history, info.qos_profile.depth}, info.qos_profile), - topic_type_hash_(info.topic_type_hash) ->>>>>>> 7f783cb (Improve the robustness of the TopicEndpointInfo constructor (#3013)) + qos_profile_({info.qos_profile.history, info.qos_profile.depth}, info.qos_profile) { if (!info.node_name || !info.node_namespace || !info.topic_type) { throw std::invalid_argument("Constructor TopicEndpointInfo with invalid topic endpoint info");