Skip to content

Commit

Permalink
Avoid case where realloc called with size 0
Browse files Browse the repository at this point in the history
  • Loading branch information
sloretz committed Sep 6, 2018
1 parent bc993e0 commit 5dc847f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions rcl/src/rcl/wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,12 @@ rcl_wait_set_resize(
const size_t num_rmw_gc = guard_conditions_size + timers_size;
// Clear added guard conditions
rmw_gcs->guard_condition_count = 0u;
if (0u == num_rmw_gc && rmw_gcs->guard_conditions) {
wait_set->impl->allocator.deallocate(
(void *)rmw_gcs->guard_conditions, wait_set->impl->allocator.state);
rmw_gcs->guard_conditions = NULL;
if (0u == num_rmw_gc) {
if (rmw_gcs->guard_conditions) {
wait_set->impl->allocator.deallocate(
(void *)rmw_gcs->guard_conditions, wait_set->impl->allocator.state);
rmw_gcs->guard_conditions = NULL;
}
} else {
rmw_gcs->guard_conditions = (void **)wait_set->impl->allocator.reallocate(
rmw_gcs->guard_conditions, sizeof(void *) * num_rmw_gc, wait_set->impl->allocator.state);
Expand Down

0 comments on commit 5dc847f

Please sign in to comment.