From 833ea2ccf347edf55c4c80bc0645a4cb4e1025c4 Mon Sep 17 00:00:00 2001 From: dukess Date: Mon, 8 May 2023 09:59:26 +0300 Subject: [PATCH] Fix: overwrite buffer in cleanupDatalog() --- BSB_LAN/BSB_LAN.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BSB_LAN/BSB_LAN.ino b/BSB_LAN/BSB_LAN.ino index d5f45084..83029439 100644 --- a/BSB_LAN/BSB_LAN.ino +++ b/BSB_LAN/BSB_LAN.ino @@ -6551,7 +6551,11 @@ next_parameter: } else if (p[2]=='K') { //--- clean up datalog, keeping only the most recent n days int nDays; if (sscanf(p+3,"%d",&nDays)==1 && nDays>0) { - printFmtToWebClient("\r\n%s\r\n",cleanupDatalog(nDays)); + // We should flush all characters to client and use errormsgptr + // beacuse cleanupDatalog() and printFmtToWebClient() use same buffer; + flushToWebClient(); + const char *errormsgptr = cleanupDatalog(nDays); + printFmtToWebClient("\r\n%s\r\n", errormsgptr); // cleanup after failed cleanupDatalog(), if necessary: SD.remove(datalogTemporaryFileName); SD.remove(datalogIndexTemporaryFileName);