aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFParser.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-08-10 14:16:06 +0200
committerm-holger <m-holger@kubitscheck.org>2022-09-01 17:59:01 +0200
commit356b582cec5be67cbf60ad64a1b2a7cab689dd77 (patch)
treee72c4dd8522c286f8078e75cd159271e45e0452c /libqpdf/QPDFParser.cc
parentc5d0428da21c9b2531fcf6b83f08a52eb7a86a4a (diff)
downloadqpdf-356b582cec5be67cbf60ad64a1b2a7cab689dd77.tar.zst
Remove QPDFObjectHandle::newIndirect
Modify QPDFParser::parse to call QPDF::getObject instead.
Diffstat (limited to 'libqpdf/QPDFParser.cc')
-rw-r--r--libqpdf/QPDFParser.cc23
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());