From 79404afd9d21a46a3e3ec07f738cee107f4261a1 Mon Sep 17 00:00:00 2001 From: 1technophile <1technophile@users.noreply.github.com> Date: Mon, 16 Jan 2017 20:35:39 +0100 Subject: [PATCH] #11 memory allocation correction --- _433nIRtoMQTTto433nIR_ESP8266.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_433nIRtoMQTTto433nIR_ESP8266.ino b/_433nIRtoMQTTto433nIR_ESP8266.ino index be8c65e..330f212 100644 --- a/_433nIRtoMQTTto433nIR_ESP8266.ino +++ b/_433nIRtoMQTTto433nIR_ESP8266.ino @@ -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);