Commit 2394acf7a688b2d080d4233d66a6e22bf46f0fca

Authored by Jay Berkenbilt
1 parent a0b1a181

Remove explicit direct object check from getObject

An indirect object reference to 0, 0 is invalid. If it appears in the
file or is parsed from a string, the parser catches it. This check
would only be useful for someone explicitly calling getObject with 0,
0, and that would trigger an error during resolve().
libqpdf/QPDF.cc
@@ -1781,9 +1781,8 @@ QPDF::readObjectAtOffset( @@ -1781,9 +1781,8 @@ QPDF::readObjectAtOffset(
1781 // not triggered by an xref lookup. 1781 // not triggered by an xref lookup.
1782 check_og = false; 1782 check_og = false;
1783 try_recovery = false; 1783 try_recovery = false;
1784 - } else {  
1785 - setLastObjectDescription(description, exp_og);  
1786 } 1784 }
  1785 + setLastObjectDescription(description, exp_og);
1787 1786
1788 if (!this->m->attempt_recovery) { 1787 if (!this->m->attempt_recovery) {
1789 try_recovery = false; 1788 try_recovery = false;
@@ -2190,9 +2189,6 @@ QPDF::reserveStream(QPDFObjGen const& og) @@ -2190,9 +2189,6 @@ QPDF::reserveStream(QPDFObjGen const& og)
2190 QPDFObjectHandle 2189 QPDFObjectHandle
2191 QPDF::getObject(QPDFObjGen const& og) 2190 QPDF::getObject(QPDFObjGen const& og)
2192 { 2191 {
2193 - if (!og.isIndirect()) {  
2194 - return QPDFObjectHandle::newNull();  
2195 - }  
2196 if (!isCached(og)) { 2192 if (!isCached(og)) {
2197 m->obj_cache[og] = ObjCache(QPDF_Unresolved::create(this, og), -1, -1); 2193 m->obj_cache[og] = ObjCache(QPDF_Unresolved::create(this, og), -1, -1);
2198 } 2194 }
qpdf/qtest/qpdf/issue-143.out
@@ -14,5 +14,6 @@ WARNING: issue-143.pdf (object 1 0, offset 21): stream dictionary lacks /Length @@ -14,5 +14,6 @@ WARNING: issue-143.pdf (object 1 0, offset 21): stream dictionary lacks /Length
14 WARNING: issue-143.pdf (object 1 0, offset 84): attempting to recover stream length 14 WARNING: issue-143.pdf (object 1 0, offset 84): attempting to recover stream length
15 WARNING: issue-143.pdf (object 1 0, offset 84): recovered stream length: 606 15 WARNING: issue-143.pdf (object 1 0, offset 84): recovered stream length: 606
16 WARNING: issue-143.pdf object stream 1 (object 2 0, offset 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 16 WARNING: issue-143.pdf object stream 1 (object 2 0, offset 33): expected dictionary key but found non-name object; inserting key /QPDFFake1
  17 +WARNING: issue-143.pdf: object 0/0 has unexpected xref entry type
17 WARNING: issue-143.pdf (object 2 0, offset 84): supposed object stream 12336 is not a stream 18 WARNING: issue-143.pdf (object 2 0, offset 84): supposed object stream 12336 is not a stream
18 qpdf: operation succeeded with warnings; resulting file may have some problems 19 qpdf: operation succeeded with warnings; resulting file may have some problems
qpdf/qtest/qpdf/obj0-check.out
@@ -5,4 +5,5 @@ checking obj0.pdf @@ -5,4 +5,5 @@ checking obj0.pdf
5 PDF Version: 1.3 5 PDF Version: 1.3
6 File is not encrypted 6 File is not encrypted
7 File is not linearized 7 File is not linearized
  8 +WARNING: obj0.pdf (offset 15): object with ID 0
8 qpdf: operation succeeded with warnings 9 qpdf: operation succeeded with warnings