Skip to content

Commit

Permalink
Remember to free request_bytes.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Jan 9, 2024
1 parent 8054227 commit 391cc39
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1954,9 +1954,12 @@ rmw_send_request(
allocator->state));
if (!request_bytes) {
RMW_SET_ERROR_MSG("failed allocate request message bytes");
allocator->deallocate(request_bytes, allocator->state);
return RMW_RET_ERROR;
}
auto free_request_bytes = rcpputils::make_scope_exit(
[request_bytes, allocator]() {
allocator->deallocate(request_bytes, allocator->state);
});

// Object that manages the raw buffer
eprosima::fastcdr::FastBuffer fastbuffer(request_bytes, max_data_length);
Expand All @@ -1971,7 +1974,6 @@ rmw_send_request(
ser,
client_data->request_type_support_impl))
{
allocator->deallocate(request_bytes, allocator->state);
return RMW_RET_ERROR;
}

Expand Down

0 comments on commit 391cc39

Please sign in to comment.