Commit 250a7364828da874fd728808f48443f8cfa5132d
1 parent
769a4915
Remove parameter overwrite from QPDF::processXRefStream
Showing
2 changed files
with
14 additions
and
22 deletions
include/qpdf/QPDF.hh
| ... | ... | @@ -1002,7 +1002,7 @@ class QPDF |
| 1002 | 1002 | qpdf_offset_t read_xrefTable(qpdf_offset_t offset); |
| 1003 | 1003 | qpdf_offset_t read_xrefStream(qpdf_offset_t offset); |
| 1004 | 1004 | qpdf_offset_t processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream); |
| 1005 | - void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false); | |
| 1005 | + void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2); | |
| 1006 | 1006 | void insertReconstructedXrefEntry(int obj, qpdf_offset_t f1, int f2); |
| 1007 | 1007 | void setLastObjectDescription(std::string const& description, QPDFObjGen const& og); |
| 1008 | 1008 | QPDFObjectHandle readObject( | ... | ... |
libqpdf/QPDF.cc
| ... | ... | @@ -1112,31 +1112,23 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj) |
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | void |
| 1115 | -QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite) | |
| 1115 | +QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2) | |
| 1116 | 1116 | { |
| 1117 | 1117 | // Populate the xref table in such a way that the first reference to an object that we see, |
| 1118 | 1118 | // which is the one in the latest xref table in which it appears, is the one that gets stored. |
| 1119 | - // This works because we are reading more recent appends before older ones. Exception: if | |
| 1120 | - // overwrite is true, then replace any existing object. This is used in xref recovery mode, | |
| 1121 | - // which reads the file from beginning to end. | |
| 1119 | + // This works because we are reading more recent appends before older ones. | |
| 1122 | 1120 | |
| 1123 | 1121 | // If there is already an entry for this object and generation in the table, it means that a |
| 1124 | 1122 | // later xref table has registered this object. Disregard this one. |
| 1125 | - { // private scope | |
| 1126 | - int gen = (f0 == 2 ? 0 : f2); | |
| 1127 | - QPDFObjGen og(obj, gen); | |
| 1128 | - if (m->xref_table.count(og)) { | |
| 1129 | - if (overwrite) { | |
| 1130 | - m->xref_table.erase(og); | |
| 1131 | - } else { | |
| 1132 | - QTC::TC("qpdf", "QPDF xref reused object"); | |
| 1133 | - return; | |
| 1134 | - } | |
| 1135 | - } | |
| 1136 | - if (m->deleted_objects.count(obj)) { | |
| 1137 | - QTC::TC("qpdf", "QPDF xref deleted object"); | |
| 1138 | - return; | |
| 1139 | - } | |
| 1123 | + | |
| 1124 | + QPDFObjGen og(obj, (f0 == 2 ? 0 : f2)); | |
| 1125 | + if (m->xref_table.count(og)) { | |
| 1126 | + QTC::TC("qpdf", "QPDF xref reused object"); | |
| 1127 | + return; | |
| 1128 | + } | |
| 1129 | + if (m->deleted_objects.count(obj)) { | |
| 1130 | + QTC::TC("qpdf", "QPDF xref deleted object"); | |
| 1131 | + return; | |
| 1140 | 1132 | } |
| 1141 | 1133 | |
| 1142 | 1134 | switch (f0) { |
| ... | ... | @@ -1147,11 +1139,11 @@ QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite) |
| 1147 | 1139 | case 1: |
| 1148 | 1140 | // f2 is generation |
| 1149 | 1141 | QTC::TC("qpdf", "QPDF xref gen > 0", ((f2 > 0) ? 1 : 0)); |
| 1150 | - m->xref_table[QPDFObjGen(obj, f2)] = QPDFXRefEntry(f1); | |
| 1142 | + m->xref_table[og] = QPDFXRefEntry(f1); | |
| 1151 | 1143 | break; |
| 1152 | 1144 | |
| 1153 | 1145 | case 2: |
| 1154 | - m->xref_table[QPDFObjGen(obj, 0)] = QPDFXRefEntry(toI(f1), f2); | |
| 1146 | + m->xref_table[og] = QPDFXRefEntry(toI(f1), f2); | |
| 1155 | 1147 | break; |
| 1156 | 1148 | |
| 1157 | 1149 | default: | ... | ... |