From ce6af2b52d67679705dbbb21b8216f2ae77b5b76 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 8 Jan 2024 23:05:32 +0000 Subject: [PATCH] Add error checking into ros_topic_name_to_zenoh_key Signed-off-by: Chris Lalancette --- rmw_zenoh_cpp/src/rmw_zenoh.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rmw_zenoh_cpp/src/rmw_zenoh.cpp b/rmw_zenoh_cpp/src/rmw_zenoh.cpp index 64ac7593..aa796a69 100644 --- a/rmw_zenoh_cpp/src/rmw_zenoh.cpp +++ b/rmw_zenoh_cpp/src/rmw_zenoh.cpp @@ -82,6 +82,9 @@ z_owned_keyexpr_t ros_topic_name_to_zenoh_key( domain_ss << domain_id; char * stripped_topic_name = rcutils_strndup( &topic_name[start_offset], end_offset - start_offset, *allocator); + if (stripped_topic_name == nullptr) { + return z_keyexpr_null(); + } z_owned_keyexpr_t keyexpr = z_keyexpr_join( z_keyexpr(domain_ss.str().c_str()), z_keyexpr(stripped_topic_name)); allocator->deallocate(stripped_topic_name, allocator->state);