Deallocate ret_val to avoid memery leak (#278)
In get_value() function ret_val is allocated from rcutils_strdup when type is DATA_TYPE_STRING, Should be deallocate in switch val_type=DATA_TYPE_STRING case. Signed-off-by: Chris Ye <chris.ye@intel.com>
This commit is contained in:
parent
1e5bf4ac29
commit
696f62c80b
1 changed files with 3 additions and 0 deletions
|
@ -964,6 +964,9 @@ static rcl_ret_t parse_value(
|
|||
allocator.zero_allocate(1U, sizeof(rcutils_string_array_t), allocator.state);
|
||||
if (NULL == param_value->string_array_value) {
|
||||
RCUTILS_SAFE_FWRITE_TO_STDERR("Error allocating mem");
|
||||
if (NULL != ret_val) {
|
||||
allocator.deallocate(ret_val, allocator.state);
|
||||
}
|
||||
return RCL_RET_BAD_ALLOC;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue