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