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 <[email protected]>
  • Loading branch information
MiguelCompany committed Jan 8, 2024
1 parent 8b6f4df commit 4d0be32
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 4d0be32

Please sign in to comment.