Skip to content

Commit

Permalink
Capture std::bad_alloc on deserializeROSmessage. (#665)
Browse files Browse the repository at this point in the history
* Capture bad_alloc on deserializeROSmessage.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 4d0be32)
  • Loading branch information
MiguelCompany authored and mergify[bot] committed Jan 16, 2024
1 parent a70758e commit 202244e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rmw_fastrtps_cpp/src/type_support_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ bool TypeSupport::deserializeROSmessage(
"Fast CDR exception deserializing message of type %s.",
getName());
return false;
} catch (const std::bad_alloc &) {
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"'Bad alloc' exception deserializing message of type %s.",
getName());
return false;
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,11 @@ bool TypeSupport<MembersType>::deserializeROSmessage(
"Fast CDR exception deserializing message of type %s.",
getName());
return false;
} catch (const std::bad_alloc &) {
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING(
"'Bad alloc' exception deserializing message of type %s.",
getName());
return false;
}

return true;
Expand Down

0 comments on commit 202244e

Please sign in to comment.