Skip to content

Commit

Permalink
Fix: Off-by-one error in payload_copy malloc. (#337)
Browse files Browse the repository at this point in the history
See Issue #336 for details.
  • Loading branch information
crankyoldgit authored Nov 12, 2017
1 parent ca97b41 commit 2c64cbf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/IRMQTTServer/IRMQTTServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
// as the orignal payload buffer will be overwritten whilst
// constructing the PUBLISH packet.
// Allocate the correct amount of memory for the payload copy
byte* payload_copy = reinterpret_cast<byte*>(malloc(length));
byte* payload_copy = reinterpret_cast<byte*>(malloc(length + 1));
// Copy the payload to the new buffer
memcpy(payload_copy, payload, length);

Expand Down

0 comments on commit 2c64cbf

Please sign in to comment.