From 0f12e107de6a900fe8d4037ab52af6f3797e143e Mon Sep 17 00:00:00 2001 From: Thulinma Date: Thu, 12 Mar 2020 15:32:24 +0100 Subject: [PATCH] Fix JSON parsing bug when a backslash was at the very end of a string --- lib/json.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/json.cpp b/lib/json.cpp index 3a90d1bf..f67e5ef5 100644 --- a/lib/json.cpp +++ b/lib/json.cpp @@ -178,7 +178,7 @@ static std::string read_string(char separator, std::istream &fromstream){ while (fromstream.good()){ char c; fromstream.get(c); - if (c == '\\'){ + if (!escaped && c == '\\'){ escaped = true; continue; } @@ -189,6 +189,7 @@ static std::string read_string(char separator, std::istream &fromstream){ } switch (c){ case 'b': out += '\b'; break; + case '\\': out += '\\'; break; case 'f': out += '\f'; break; case 'n': out += '\n'; break; case 'r': out += '\r'; break;