summaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-11-20 19:15:14 +0100
committerJay Berkenbilt <ejb@ql.org>2012-11-20 19:57:37 +0100
commitf256670eba636a9b8344987108110e7b1b4c0a46 (patch)
treeda0cc0248dfc71cf2de5c76a60f99b9918d5c2d1 /libqpdf
parent041397fdabde66574824db7582a26ef1e3fbfc65 (diff)
downloadqpdf-f256670eba636a9b8344987108110e7b1b4c0a46.tar.zst
Ignore objects with offset 0
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 678f773e..ccbfaf7c 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -1253,6 +1253,21 @@ QPDF::readObjectAtOffset(bool try_recovery,
int& objid, int& generation)
{
setLastObjectDescription(description, exp_objid, exp_generation);
+
+ // Special case: if offset is 0, just return null. Some PDF
+ // writers, in particuar "Mac OS X 10.7.5 Quartz PDFContext", may
+ // store deleted objects in the xref table as "0000000000 00000
+ // n", which is not correct, but it won't hurt anything for to
+ // ignore these.
+ if (offset == 0)
+ {
+ QTC::TC("qpdf", "QPDF bogus 0 offset", 0);
+ warn(QPDFExc(qpdf_e_damaged_pdf, this->file->getName(),
+ this->last_object_description, 0,
+ "object has offset 0"));
+ return QPDFObjectHandle::newNull();
+ }
+
this->file->seek(offset, SEEK_SET);
QPDFTokenizer::Token tobjid = readToken(this->file);