2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-02 22:50:20 +00:00

In Xref_table::insert combine deleted / replaced object checks

This commit is contained in:
m-holger 2024-10-24 12:00:18 +01:00
parent 6edffc495c
commit e8849ebe35
2 changed files with 6 additions and 12 deletions

View File

@ -1031,12 +1031,12 @@ Xref_table::insert(int obj, int f0, qpdf_offset_t f1, int f2)
auto& entry = table[static_cast<size_t>(obj)];
auto old_type = entry.type();
if (!old_type && entry.gen() > 0) {
if ((!old_type && entry.gen() > 0) || (old_type && entry.gen() >= new_gen)) {
// At the moment we are processing the updates last to first and therefore the gen doesn't
// matter as long as it > 0 to distinguish it from an uninitialized entry. This will need
// to be revisited when we want to support incremental updates or more comprehensive
// checking.
QTC::TC("qpdf", "QPDF xref deleted object");
// matter for deleted objects as long as gen > 0 to distinguish it from an uninitialized
// entry. This will need to be revisited when we want to support incremental updates or more
// comprehensive checking.
QTC::TC("qpdf", "QPDF xref replaced / deleted object", old_type == 0 ? 0 : 1);
return;
}
@ -1046,11 +1046,6 @@ Xref_table::insert(int obj, int f0, qpdf_offset_t f1, int f2)
return;
}
if (old_type && entry.gen() >= new_gen) {
QTC::TC("qpdf", "QPDF xref reused object");
return;
}
switch (f0) {
case 1:
// f2 is generation

View File

@ -46,7 +46,6 @@ QPDFWriter write to file 0
QPDF lin write nshared_total > nshared_first_page 1
QPDFWriter encrypted hint stream 0
QPDF opt inherited scalar 0
QPDF xref reused object 0
QPDF xref gen > 0 1
QPDF not a pdf file 0
QPDF can't find startxref 0
@ -83,7 +82,7 @@ QPDF prev key in xref stream dictionary 0
QPDF prev key in trailer dictionary 0
QPDF found xref stream 0
QPDF ignoring XRefStm in trailer 0
QPDF xref deleted object 0
QPDF xref replaced / deleted object 1
SF_FlateLzwDecode PNG filter 0
QPDF xref /Index is null 0
QPDF xref /Index is array 1