diff options
author | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2022-09-01 19:14:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 19:14:56 +0200 |
commit | f8fd7d60e301b9b1bf4d705ce747e281c320487e (patch) | |
tree | 4aba6da08ae9d441ecf57eabefdc76185137d28d /libqpdf/QPDFParser.cc | |
parent | a078202c1b5823f1c13a4c559619158054029e73 (diff) | |
parent | 805c1ad47968e33e1296af9a31492f6916ad9113 (diff) | |
download | qpdf-f8fd7d60e301b9b1bf4d705ce747e281c320487e.tar.zst |
Merge pull request #726 from m-holger/tidy3
Split QPDFObject into QPDFObject and QPDFValue
Diffstat (limited to 'libqpdf/QPDFParser.cc')
-rw-r--r-- | libqpdf/QPDFParser.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc index ccdd9db0..9aa1f426 100644 --- a/libqpdf/QPDFParser.cc +++ b/libqpdf/QPDFParser.cc @@ -1,8 +1,8 @@ #include <qpdf/QPDFParser.hh> #include <qpdf/QPDF.hh> +#include <qpdf/QPDFObjGen.hh> #include <qpdf/QPDFObjectHandle.hh> -#include <qpdf/QPDF_Array.hh> #include <qpdf/QTC.hh> #include <qpdf/QUtil.hh> @@ -55,6 +55,7 @@ QPDFParser::parse(bool& empty, bool content_stream) while (!done) { bool bad = false; + bool indirect_ref = false; is_null = false; auto& frame = stack.back(); auto& olist = frame.olist; @@ -185,12 +186,16 @@ QPDFParser::parse(bool& empty, bool content_stream) "QPDFObjectHandle::parse called without context" " on an object with indirect references"); } - // Try to resolve indirect objects - object = QPDFObjectHandle::newIndirect( - context, - QPDFObjGen( - olist.at(size - 2).getIntValueAsInt(), - olist.back().getIntValueAsInt())); + auto ref_og = QPDFObjGen( + olist.at(size - 2).getIntValueAsInt(), + olist.back().getIntValueAsInt()); + if (ref_og.isIndirect()) { + object = context->getObject(ref_og); + indirect_ref = true; + } else { + QTC::TC("qpdf", "QPDFParser indirect with 0 objid"); + is_null = true; + } olist.pop_back(); olist.pop_back(); } else if ((value == "endobj") && (state == st_top)) { @@ -274,8 +279,8 @@ QPDFParser::parse(bool& empty, bool content_stream) case st_dictionary: case st_array: - if (!object.isDirectNull()) { - // No need to set description for direct nulls- they will + if (!indirect_ref && !object.isDirectNull()) { + // No need to set description for direct nulls - they will // become implicit. setDescriptionFromInput(object, input->getLastOffset()); object.setParsedOffset(input->getLastOffset()); |