From 6f94a3a89ab4dc7be0c053c53a94868b6c9a747c Mon Sep 17 00:00:00 2001 From: m-holger Date: Thu, 26 Jan 2023 13:48:29 +0000 Subject: In JSONParser::handleToken move string decoding into switch statement --- libqpdf/JSON.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc index 218ea724..ef652a86 100644 --- a/libqpdf/JSON.cc +++ b/libqpdf/JSON.cc @@ -1135,16 +1135,7 @@ JSONParser::handleToken() ": material follows end of object: " + token); } - // Git string value std::string s_value; - if (lex_state == ls_string) { - // Token includes the quotation marks - if (token.length() < 2) { - throw std::logic_error("JSON string length < 2"); - } - s_value = decode_string(token, token_start); - } - std::shared_ptr item; switch (lex_state) { @@ -1185,6 +1176,11 @@ JSONParser::handleToken() break; case ls_string: + // Token includes the quotation marks + if (token.length() < 2) { + throw std::logic_error("JSON string length < 2"); + } + s_value = decode_string(token, token_start); item = std::make_shared(JSON::makeString(s_value)); break; -- cgit v1.2.3-54-g00ecf