diff --git a/rmw_zenoh_cpp/src/rmw_init_options.cpp b/rmw_zenoh_cpp/src/rmw_init_options.cpp index 61dbc1fa..2b79566a 100644 --- a/rmw_zenoh_cpp/src/rmw_init_options.cpp +++ b/rmw_zenoh_cpp/src/rmw_init_options.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include "detail/identifier.hpp" #include "detail/rmw_init_options_impl.hpp" @@ -40,6 +41,7 @@ rmw_init_options_init(rmw_init_options_t * init_options, rcutils_allocator_t all return RMW_RET_INVALID_ARGUMENT; } + memset(init_options, 0, sizeof(rmw_init_options_t)); init_options->instance_id = 0; init_options->implementation_identifier = rmw_zenoh_cpp::rmw_zenoh_identifier; init_options->allocator = allocator; @@ -47,7 +49,6 @@ rmw_init_options_init(rmw_init_options_t * init_options, rcutils_allocator_t all init_options->enclave = nullptr; init_options->domain_id = RMW_DEFAULT_DOMAIN_ID; init_options->security_options = rmw_get_default_security_options(); - init_options->localhost_only = RMW_LOCALHOST_ONLY_DEFAULT; init_options->discovery_options = rmw_get_zero_initialized_discovery_options(); return rmw_discovery_options_init(&(init_options->discovery_options), 0, &allocator); } @@ -76,9 +77,8 @@ rmw_init_options_copy(const rmw_init_options_t * src, rmw_init_options_t * dst) RCUTILS_CHECK_ALLOCATOR(&allocator, return RMW_RET_INVALID_ARGUMENT); rmw_init_options_t tmp; - tmp.instance_id = src->instance_id; + memcpy(&tmp, src, sizeof(rmw_init_options_t)); tmp.implementation_identifier = rmw_zenoh_cpp::rmw_zenoh_identifier; - tmp.domain_id = src->domain_id; tmp.security_options = rmw_get_zero_initialized_security_options(); rmw_ret_t ret = rmw_security_options_copy(&src->security_options, &allocator, &tmp.security_options); @@ -89,7 +89,6 @@ rmw_init_options_copy(const rmw_init_options_t * src, rmw_init_options_t * dst) [&tmp, allocator]() { rmw_security_options_fini(&tmp.security_options, &allocator); }); - tmp.localhost_only = src->localhost_only; tmp.discovery_options = rmw_get_zero_initialized_discovery_options(); ret = rmw_discovery_options_copy( &src->discovery_options,