From 2efa6f2accd1fc0a22a4db12fcb640b5e1d0b287 Mon Sep 17 00:00:00 2001 From: 1technophile <1technophile@users.noreply.github.com> Date: Mon, 16 Jan 2017 20:36:31 +0100 Subject: [PATCH] #11 memory allocation correction --- _433toMQTTto433_ESP8266.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_433toMQTTto433_ESP8266.ino b/_433toMQTTto433_ESP8266.ino index 02213f9..72178c5 100644 --- a/_433toMQTTto433_ESP8266.ino +++ b/_433toMQTTto433_ESP8266.ino @@ -74,7 +74,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);