diff --git a/include/ros_msg_parser/helper_functions.hpp b/include/ros_msg_parser/helper_functions.hpp index e5e023e..e6a33dc 100644 --- a/include/ros_msg_parser/helper_functions.hpp +++ b/include/ros_msg_parser/helper_functions.hpp @@ -97,6 +97,11 @@ template <> inline void ReadFromBuffer( const Span& buffer, size_ throw std::runtime_error("Buffer overrun in RosMsgParser::ReadFromBuffer"); } + if (string_size == 0) { + destination = std::string(); + return; + } + const char* buffer_ptr = reinterpret_cast( &buffer[offset] ); offset += string_size;