Commit 6f94a3a89ab4dc7be0c053c53a94868b6c9a747c

Authored by m-holger
1 parent fcc123a6

In JSONParser::handleToken move string decoding into switch statement

Showing 1 changed file with 5 additions and 9 deletions
libqpdf/JSON.cc
... ... @@ -1135,16 +1135,7 @@ JSONParser::handleToken()
1135 1135 ": material follows end of object: " + token);
1136 1136 }
1137 1137  
1138   - // Git string value
1139 1138 std::string s_value;
1140   - if (lex_state == ls_string) {
1141   - // Token includes the quotation marks
1142   - if (token.length() < 2) {
1143   - throw std::logic_error("JSON string length < 2");
1144   - }
1145   - s_value = decode_string(token, token_start);
1146   - }
1147   -
1148 1139 std::shared_ptr<JSON> item;
1149 1140  
1150 1141 switch (lex_state) {
... ... @@ -1185,6 +1176,11 @@ JSONParser::handleToken()
1185 1176 break;
1186 1177  
1187 1178 case ls_string:
  1179 + // Token includes the quotation marks
  1180 + if (token.length() < 2) {
  1181 + throw std::logic_error("JSON string length < 2");
  1182 + }
  1183 + s_value = decode_string(token, token_start);
1188 1184 item = std::make_shared<JSON>(JSON::makeString(s_value));
1189 1185 break;
1190 1186  
... ...