From c7e1961e26a6034e12571545196777c3bc202762 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 2 Feb 2018 13:44:08 -0800 Subject: [PATCH] handle node names which are null --- rclcpp/src/rclcpp/node_interfaces/node_graph.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp b/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp index 2feb8f03f2..bceacc8979 100644 --- a/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp +++ b/rclcpp/src/rclcpp/node_interfaces/node_graph.cpp @@ -149,8 +149,12 @@ NodeGraph::get_node_names() const throw std::runtime_error(error_msg); } - std::vector node_names(&node_names_c.data[0], - &node_names_c.data[0 + node_names_c.size]); + std::vector node_names(node_names_c.size); + for (size_t i = 0; i < node_names_c.size; ++i) { + if (node_names_c.data[i]) { + node_names[i] = node_names_c.data[i]; + } + } ret = rcutils_string_array_fini(&node_names_c); if (ret != RCUTILS_RET_OK) { // *INDENT-OFF*