From df959399cdb60aa3f547ee84cb5c4e9afafa9520 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 29 Sep 2024 16:46:06 -0500 Subject: [PATCH] DivConfig: fx pssib issue whn line's lngr thn 4095 maybe issue #2025 --- src/engine/config.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/config.cpp b/src/engine/config.cpp index 07cb728d0..213c9f0bd 100644 --- a/src/engine/config.cpp +++ b/src/engine/config.cpp @@ -115,6 +115,8 @@ void DivConfig::parseLine(const char* line) { bool DivConfig::loadFromFile(const char* path, bool createOnFail, bool redundancy) { char line[4096]; + String lineStr; + lineStr.reserve(4096); logD("opening config for read: %s",path); FILE* f=NULL; @@ -210,7 +212,15 @@ bool DivConfig::loadFromFile(const char* path, bool createOnFail, bool redundanc if (fgets(line,4095,f)==NULL) { break; } - parseLine(line); + lineStr+=line; + if (!lineStr.empty() && !feof(f)) { + if (lineStr[lineStr.size()-1]!='\n') { + continue; + } + } + parseLine(lineStr.c_str()); + lineStr=""; + lineStr.reserve(4096); } logD("end of file (%s)",strerror(errno)); fclose(f);