Skip to content

Commit

Permalink
fix #1 (publisher crash when handling zero length payload)
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky authored and FlorianReimold committed Jan 13, 2022
1 parent 00eb000 commit eae093f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tcp_pubsub/src/publisher_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,11 @@ namespace tcp_pubsub
size_t current_position = header_size;
for (const auto& payload : payloads)
{
memcpy(&((*buffer)[current_position]), payload.first, payload.second);
current_position += payload.second;
if (payload.first && (payload.second > 0))
{
memcpy(&((*buffer)[current_position]), payload.first, payload.second);
current_position += payload.second;
}
}
}

Expand Down

0 comments on commit eae093f

Please sign in to comment.