diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-01-04 16:17:33 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-01-04 16:29:29 +0100 |
commit | a01359189b32c60c2d55b039f7aefd6c3ce0ebde (patch) | |
tree | 9f0f3041db8b4a160605c9e22aa4b2988ff2951f /include | |
parent | 158156d5062a5ac335bcfde7893be4671affdc32 (diff) | |
download | qpdf-a01359189b32c60c2d55b039f7aefd6c3ce0ebde.tar.zst |
Fix dangling references (fixes #240)
On certain operations, such as iterating through all objects and
adding new indirect objects, walk through the entire object structure
and explicitly resolve any indirect references to non-existent
objects. That prevents new objects from springing into existence and
causing the previously dangling references to point to them.
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDF.hh | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 2e27d831..34e0ad31 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -431,9 +431,21 @@ class QPDF QPDF_DLL void showXRefTable(); + // Detect all indirect references to objects that don't exist and + // resolve them by replacing them with null, which is how the PDF + // spec says to interpret such dangling references. This method is + // called automatically if you try to add any new objects, if you + // call getAllObjects, and before a file is written. The qpdf + // object caches whether it has run this to avoid running it + // multiple times. You can pass true to force it to run again if + // you have explicitly added new objects that may have additional + // dangling references. + QPDF_DLL + void fixDanglingReferences(bool force = false); + // Return the approximate number of indirect objects. It is // approximate because not all objects in the file are preserved - // in all cases. + // in all cases, and gaps in object numbering are not preserved. QPDF_DLL size_t getObjectCount(); @@ -1199,6 +1211,7 @@ class QPDF CopiedStreamDataProvider* copied_stream_data_provider; std::set<QPDFObjGen> attachment_streams; bool reconstructed_xref; + bool fixed_dangling_refs; // Linearization data qpdf_offset_t first_xref_item_offset; // actual value from file |