Skip to content

Commit 254792a

Browse files
committed
fix two bugs in new init code
1 parent 12a4f0a commit 254792a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

rcl/src/rcl/init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C"
2828
#include "rcutils/stdatomic_helper.h"
2929
#include "rmw/error_handling.h"
3030

31-
static atomic_uint_least64_t __rcl_next_unique_id = ATOMIC_VAR_INIT(0);
31+
static atomic_uint_least64_t __rcl_next_unique_id = ATOMIC_VAR_INIT(1);
3232

3333
rcl_ret_t
3434
rcl_init(
@@ -72,6 +72,8 @@ rcl_init(
7272
context->impl = allocator.allocate(sizeof(rcl_context_impl_t), allocator.state);
7373
RCL_CHECK_FOR_NULL_WITH_MSG(
7474
context->impl, "failed to allocate memory for context impl", return RCL_RET_BAD_ALLOC);
75+
// memset to 0 so the cleanup function will not try to clean up uninitialized parts later
76+
memset(context->impl, 0x0, sizeof(rcl_context_impl_t));
7577

7678
// Copy the options into the context for future reference.
7779
rcl_ret_t ret = rcl_init_options_copy(options, &(context->impl->init_options));

0 commit comments

Comments
 (0)