Skip to content

Commit

Permalink
Fix memory leak that string not deleted. (ros2#224)
Browse files Browse the repository at this point in the history
Signed-off-by: Chen.Lihui <[email protected]>
  • Loading branch information
Chen Lihui authored Aug 26, 2020
1 parent 217259a commit 416c01d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions rmw_cyclonedds_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,21 @@ static void handle_ParticipantEntitiesInfo(dds_entity_t reader, void * arg)
{
static_cast<void>(reader);
rmw_context_impl_t * impl = static_cast<rmw_context_impl_t *>(arg);
ParticipantEntitiesInfo msg;
bool taken;
while (rmw_take(impl->common.sub, &msg, &taken, nullptr) == RMW_RET_OK && taken) {
// locally published data is filtered because of the subscription QoS
impl->common.graph_cache.update_participant_entities(msg);
}
do {
// TODO(iuhilnehc-ynos): Fix memory leak that string not deleted. (#224)
// This is a workaround to make sure calling destructor of ParticipantEntitiesInfo
// after calling rmw_take each time, otherwise, there will be a memory leak while
// deserializing a long enough buffer into a string member of NodeEntitiesInfo
// in ParticipantEntitiesInfo.
ParticipantEntitiesInfo msg;
if (rmw_take(impl->common.sub, &msg, &taken, nullptr) == RMW_RET_OK && taken) {
// locally published data is filtered because of the subscription QoS
impl->common.graph_cache.update_participant_entities(msg);
} else {
break;
}
} while (1);
}

static void handle_DCPSParticipant(dds_entity_t reader, void * arg)
Expand Down

0 comments on commit 416c01d

Please sign in to comment.