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 <carlosferreira@eprosima.com>

* Apply suggestion

Co-authored-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
cferreiragonz and MiguelCompany authored Mar 8, 2024
1 parent 5c87d9d commit 08193d5
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 @@ -265,11 +265,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 @@ -278,11 +282,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 08193d5

Please sign in to comment.