Skip to content

Commit

Permalink
Add missing allocator check for NULL (#606)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
  • Loading branch information
Blast545 authored Apr 7, 2020
1 parent 3eda4b9 commit 00aaea7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rcl/src/rcl/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ rcl_ros_clock_init(
RCL_CHECK_ARGUMENT_FOR_NULL(allocator, RCL_RET_INVALID_ARGUMENT);
rcl_init_generic_clock(clock);
clock->data = allocator->allocate(sizeof(rcl_ros_clock_storage_t), allocator->state);
if (NULL == clock->data) {
RCL_SET_ERROR_MSG("allocating memory failed");
return RCL_RET_BAD_ALLOC;
}

rcl_ros_clock_storage_t * storage = (rcl_ros_clock_storage_t *)clock->data;
// 0 is a special value meaning time has not been set
atomic_init(&(storage->current_time), 0);
Expand Down

0 comments on commit 00aaea7

Please sign in to comment.