aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-01-27 16:39:16 +0100
committerm-holger <m-holger@kubitscheck.org>2023-02-04 14:53:23 +0100
commit6748bd33f75da96fc45d189028207a392c421eec (patch)
treea8a7aefc6576304f562784418ac207b05b63db0d
parent29093a167b3f628d23b5a7890404eab659c6a685 (diff)
downloadqpdf-6748bd33f75da96fc45d189028207a392c421eec.tar.zst
In JSONParser::handleToken remove next_state
-rw-r--r--libqpdf/JSON.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index 41481660..8c69c4e9 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -1258,8 +1258,6 @@ JSONParser::handleToken()
break;
}
- parser_state_e next_state = ps_top;
-
item->setStart(token_start);
item->setEnd(offset);
@@ -1282,7 +1280,7 @@ JSONParser::handleToken()
if (!reactor || !reactor->dictionaryItem(dict_key, *item)) {
tos->addDictionaryMember(dict_key, *item);
}
- next_state = ps_dict_after_item;
+ parser_state = ps_dict_after_item;
break;
case ps_array_begin:
@@ -1290,12 +1288,16 @@ JSONParser::handleToken()
if (!reactor || !reactor->arrayItem(*item)) {
tos->addArrayElement(*item);
}
- next_state = ps_array_after_item;
+ parser_state = ps_array_after_item;
break;
case ps_top:
- stack.push_back(item);
- next_state = ps_done;
+ if (!(item->isDictionary() || item->isArray())) {
+ stack.push_back(item);
+ parser_state = ps_done;
+ return;
+ }
+ parser_state = ps_done;
break;
case ps_dict_after_key:
@@ -1323,7 +1325,7 @@ JSONParser::handleToken()
if (item->isDictionary() || item->isArray()) {
stack.push_back(item);
- ps_stack.push_back(next_state);
+ ps_stack.push_back(parser_state);
// Calling container start method is postponed until after
// adding the containers to their parent containers, if any.
// This makes it much easier to keep track of the current
@@ -1332,12 +1334,12 @@ JSONParser::handleToken()
if (reactor) {
reactor->dictionaryStart();
}
- next_state = ps_dict_begin;
+ parser_state = ps_dict_begin;
} else if (item->isArray()) {
if (reactor) {
reactor->arrayStart();
}
- next_state = ps_array_begin;
+ parser_state = ps_array_begin;
}
if (ps_stack.size() > 500) {
@@ -1346,7 +1348,6 @@ JSONParser::handleToken()
": maximum object depth exceeded");
}
}
- parser_state = next_state;
}
std::shared_ptr<JSON>