From b973cce49b87a1285fe1c851860474fdc1683267 Mon Sep 17 00:00:00 2001 From: franchioping Date: Sat, 15 Jun 2024 20:29:28 +0100 Subject: [PATCH] Fix malloc/free in recv Signed-off-by: franchioping --- recv/recv.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recv/recv.ino b/recv/recv.ino index 2910912..30b2037 100644 --- a/recv/recv.ino +++ b/recv/recv.ino @@ -116,10 +116,11 @@ void loop() { */ char* data_string = (char*) malloc(radio.DATALEN+1); if(data_string != NULL){ - memcpy(data_string, radio) + memcpy(data_string, radio, radio.DATALEN); data_string[radio.DATALEN] = '\0'; Serial.println(data_string); + free(data_string); }else{ Serial.print("Failed to malloc string, not printing the packet"); }