#11 memory allocation correction
This commit is contained in:
1 parent
ce9f99f3f6
commit
79404afd9d
1 file changed
+1
-1
@@ -98,7 +98,7 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// constructing the PUBLISH packet.
|
||||
trc("Hey I got a callback ");
|
||||
// Allocate the correct amount of memory for the payload copy
|
||||
byte* p = (byte*)malloc(length);
|
||||
byte* p = (byte*)malloc(length + 1);
|
||||
// Copy the payload to the new buffer
|
||||
memcpy(p,payload,length);
|
||||
|
||||
|
||||
Reference in new issue
Block a user