diff --git a/rmw_fastrtps_cpp/src/functions.cpp b/rmw_fastrtps_cpp/src/functions.cpp index 75ad0d601..a06674d94 100644 --- a/rmw_fastrtps_cpp/src/functions.cpp +++ b/rmw_fastrtps_cpp/src/functions.cpp @@ -300,6 +300,7 @@ extern "C" static_cast(malloc(sizeof(char) * strlen(name) + 1)); if (!node_handle->name) { RMW_SET_ERROR_MSG("failed to allocate memory"); + free(node_handle); return NULL; } memcpy(const_cast(node_handle->name), name, strlen(name) + 1);