From cfa529e9e7eeab66de00b814b8fc7d6fa0eb9fd2 Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 3 Sep 2018 19:27:46 +0100 Subject: [PATCH] Function was crashing , with ALARM:10 as overflowing array. replaced with larger array + use of snprintf to truncate rather than overflow in the future. --- Grbl_Esp32/report.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Grbl_Esp32/report.cpp b/Grbl_Esp32/report.cpp index 10cefd05..7e1f5fca 100644 --- a/Grbl_Esp32/report.cpp +++ b/Grbl_Esp32/report.cpp @@ -123,12 +123,11 @@ void report_status_message(uint8_t status_code) // Prints alarm messages. void report_alarm_message(uint8_t alarm_code) { - char alarm[10]; - - sprintf(alarm, "ALARM:%d\r\n", alarm_code); + char alarm[32]; + snprintf(alarm, 32, "ALARM:%d\r\n", alarm_code); grbl_send(alarm); - - delay_ms(500); // Force delay to ensure message clears serial write buffer. + + delay_ms(500); // Force delay to ensure message clears serial write buffer. } // Prints feedback messages. This serves as a centralized method to provide additional