Skip to content

Commit

Permalink
Add guards to Service::finalize()
Browse files Browse the repository at this point in the history
  • Loading branch information
asorbini committed Mar 5, 2021
1 parent 0def394 commit fac1c1b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions rmw_connextdds_common/src/common/rmw_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,7 @@ RMW_Connext_Client::finalize()
return RMW_RET_ERROR;
}
delete this->request_pub;
this->request_pub = nullptr;
}

if (nullptr != this->reply_sub) {
Expand All @@ -3037,6 +3038,7 @@ RMW_Connext_Client::finalize()
}

delete this->reply_sub;
this->reply_sub = nullptr;
}

return RMW_RET_OK;
Expand Down Expand Up @@ -3279,20 +3281,26 @@ RMW_Connext_Service::send_response(
rmw_ret_t
RMW_Connext_Service::finalize()
{
if (RMW_RET_OK != this->publisher()->finalize()) {
RMW_CONNEXT_LOG_ERROR("failed to finalize service publisher")
return RMW_RET_ERROR;
if (nullptr != this->reply_pub) {
if (RMW_RET_OK != this->reply_pub->finalize()) {
RMW_CONNEXT_LOG_ERROR("failed to finalize service publisher")
return RMW_RET_ERROR;
}

delete this->reply_pub;
this->reply_pub = nullptr;
}

delete this->publisher();
if (nullptr != this->request_sub) {
if (RMW_RET_OK != this->request_sub->finalize()) {
RMW_CONNEXT_LOG_ERROR("failed to finalize service subscriber")
return RMW_RET_ERROR;
}

if (RMW_RET_OK != this->subscriber()->finalize()) {
RMW_CONNEXT_LOG_ERROR("failed to finalize service subscriber")
return RMW_RET_ERROR;
delete this->request_sub;
this->request_sub = nullptr;
}

delete this->subscriber();

return RMW_RET_OK;
}

Expand Down

0 comments on commit fac1c1b

Please sign in to comment.