diff --git a/rmw_fastrtps_cpp/src/type_support_common.cpp b/rmw_fastrtps_cpp/src/type_support_common.cpp index 4e5dff1dc..eb3d38232 100644 --- a/rmw_fastrtps_cpp/src/type_support_common.cpp +++ b/rmw_fastrtps_cpp/src/type_support_common.cpp @@ -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; diff --git a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp index f673fe073..899119f88 100644 --- a/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp +++ b/rmw_fastrtps_dynamic_cpp/include/rmw_fastrtps_dynamic_cpp/TypeSupport_impl.hpp @@ -983,6 +983,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;