From a4643246175598e51ca1f16596c971e46eb84c5e Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 21 Aug 2021 00:46:36 -0400 Subject: [PATCH] CmdConfig: Properly preserve comments at the end of the line Trailing comments previously caused crash of the application. Closes #2581. --- src/commands/CmdConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index 03fc6e6ba..6813ffd1f 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -80,8 +80,9 @@ bool CmdConfig::setConfigVariable ( { auto new_line = line.substr (0, pos + name.length () + 1) + json::encode (value); + // Preserve the comment if (comment != std::string::npos) - line += ' ' + line.substr (comment); + new_line += " " + line.substr (comment); // Rewrite the line line = new_line;