aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
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
parentc5d0428da21c9b2531fcf6b83f08a52eb7a86a4a (diff)
downloadqpdf-356b582cec5be67cbf60ad64a1b2a7cab689dd77.tar.zst
Remove QPDFObjectHandle::newIndirect
Modify QPDFParser::parse to call QPDF::getObject instead.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFObjectHandle.cc14
-rw-r--r--libqpdf/QPDFParser.cc23
2 files changed, 14 insertions, 23 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index aae06529..d4a75fae 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -2003,20 +2003,6 @@ QPDFObjectHandle::getParsedOffset()
}
QPDFObjectHandle
-QPDFObjectHandle::newIndirect(QPDF* qpdf, QPDFObjGen const& og)
-{
- if (!og.isIndirect()) {
- // Special case: QPDF uses objid 0 as a sentinel for direct
- // objects, and the PDF specification doesn't allow for object
- // 0. Treat indirect references to object 0 as null so that we
- // never create an indirect object with objid 0.
- QTC::TC("qpdf", "QPDFObjectHandle indirect with 0 objid");
- return newNull();
- }
- return QPDFObjectHandle(qpdf, og, QPDF_Unresolved::create());
-}
-
-QPDFObjectHandle
QPDFObjectHandle::newBool(bool value)
{
return QPDFObjectHandle(QPDF_Bool::create(value));
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());