Skip to content

Commit

Permalink
Protect asio exception hotfix (#4527)
Browse files Browse the repository at this point in the history
* Refs #20599: Handle error code before function call

Signed-off-by: cferreiragonz <[email protected]>

* Apply suggestion

Co-authored-by: Miguel Company <[email protected]>

---------

Signed-off-by: cferreiragonz <[email protected]>
Co-authored-by: Miguel Company <[email protected]>
(cherry picked from commit 08193d5)
  • Loading branch information
cferreiragonz committed Mar 8, 2024
1 parent 7480818 commit 085d73a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cpp/rtps/transport/TCPTransportInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,15 @@ Locator TCPTransportInterface::remote_endpoint_to_locator(
{
Locator locator;
asio::error_code ec;
endpoint_to_locator(channel->remote_endpoint(ec), locator);
auto endpoint = channel->remote_endpoint(ec);
if (ec)
{
LOCATOR_INVALID(locator);
}
else
{
endpoint_to_locator(endpoint, locator);
}
return locator;
}

Expand All @@ -279,11 +283,15 @@ Locator TCPTransportInterface::local_endpoint_to_locator(
{
Locator locator;
asio::error_code ec;
endpoint_to_locator(channel->local_endpoint(ec), locator);
auto endpoint = channel->local_endpoint(ec);
if (ec)
{
LOCATOR_INVALID(locator);
}
else
{
endpoint_to_locator(endpoint, locator);
}
return locator;
}

Expand Down

0 comments on commit 085d73a

Please sign in to comment.