Since rmw_allocate() was used to allocate memory, we should use rmw_free() to cleanup. Otherwise, if the user provided a custom allocator to the context we will be calling deallocate with the wrong allocator. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This commit is contained in:
parent
fea44ac445
commit
ef8d7532dc
1 changed files with 3 additions and 4 deletions
|
@ -1347,10 +1347,9 @@ extern "C" rmw_ret_t rmw_destroy_node(rmw_node_t * node)
|
||||||
}
|
}
|
||||||
|
|
||||||
rmw_context_t * context = node->context;
|
rmw_context_t * context = node->context;
|
||||||
rcutils_allocator_t allocator = context->options.allocator;
|
rmw_free(const_cast<char *>(node->name));
|
||||||
allocator.deallocate(const_cast<char *>(node->name), allocator.state);
|
rmw_free(const_cast<char *>(node->namespace_));
|
||||||
allocator.deallocate(const_cast<char *>(node->namespace_), allocator.state);
|
rmw_node_free(const_cast<rmw_node_t *>(node));
|
||||||
allocator.deallocate(node, allocator.state);
|
|
||||||
delete node_impl;
|
delete node_impl;
|
||||||
context->impl->fini();
|
context->impl->fini();
|
||||||
return result_ret;
|
return result_ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue