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:
Chris Ye 2018-08-16 05:56:17 +08:00 committed by Michael Carroll
parent 1e5bf4ac29
commit 696f62c80b

View file

@ -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 {