diff options
author | m-holger <m-holger@kubitscheck.org> | 2023-10-27 18:55:09 +0200 |
---|---|---|
committer | m-holger <m-holger@kubitscheck.org> | 2023-11-01 16:38:01 +0100 |
commit | d904eab84c008325289bfb7ddcf60256b36a1b67 (patch) | |
tree | 00c57a55bd54e4bd4e484068ed22268eab6b7b47 | |
parent | 90829228b814c6fe3ea3192da34db90dc1e36843 (diff) | |
download | qpdf-d904eab84c008325289bfb7ddcf60256b36a1b67.tar.zst |
In QPDFParser::parse refactor handling of array_open and dict_open tokens
-rw-r--r-- | libqpdf/QPDFParser.cc | 14 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDFParser.hh | 2 |
2 files changed, 4 insertions, 12 deletions
diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc index 5bff6af3..12a53851 100644 --- a/libqpdf/QPDFParser.cc +++ b/libqpdf/QPDFParser.cc @@ -227,20 +227,15 @@ QPDFParser::parse(bool& empty, bool content_stream) if (stack.size() > 500) { QTC::TC("qpdf", "QPDFParser too deep"); warn("ignoring excessively deeply nested data structure"); - if (tooManyBadTokens()) { - return {QPDF_Null::create()}; - } - is_null = true; - state = st_top; + return {QPDF_Null::create()}; } else { - state = st_start; state_stack.push_back( (tokenizer.getType() == QPDFTokenizer::tt_array_open) ? st_array : st_dictionary); b_contents = false; stack.emplace_back(input); + continue; } - break; case QPDFTokenizer::tt_bool: object = QPDF_Bool::create((tokenizer.getValue() == "true")); @@ -349,7 +344,7 @@ QPDFParser::parse(bool& empty, bool content_stream) break; } - if (object == nullptr && !is_null && state != st_start) { + if (object == nullptr && !is_null) { throw std::logic_error("QPDFParser:parseInternal: unexpected uninitialized object"); } @@ -369,9 +364,6 @@ QPDFParser::parse(bool& empty, bool content_stream) case st_top: done = true; break; - - case st_start: - break; } } diff --git a/libqpdf/qpdf/QPDFParser.hh b/libqpdf/qpdf/QPDFParser.hh index 48bd594e..b9274824 100644 --- a/libqpdf/qpdf/QPDFParser.hh +++ b/libqpdf/qpdf/QPDFParser.hh @@ -31,7 +31,7 @@ class QPDFParser QPDFObjectHandle parse(bool& empty, bool content_stream); private: - enum parser_state_e { st_top, st_start, st_dictionary, st_array }; + enum parser_state_e { st_top, st_dictionary, st_array }; bool tooManyBadTokens(); void warn(qpdf_offset_t offset, std::string const& msg) const; |