Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from Intermodalics/fix/parsing-of-empty-strings
Browse files Browse the repository at this point in the history
Fix ReadFromBuffer() for empty strings in debug mode
  • Loading branch information
facontidavide authored Oct 18, 2021
2 parents 6068882 + 0cb17e5 commit 37cb15a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/ros_msg_parser/helper_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ template <> inline void ReadFromBuffer( const Span<const uint8_t>& 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<const char*>( &buffer[offset] );
offset += string_size;

Expand Down

0 comments on commit 37cb15a

Please sign in to comment.