Commit d3dacd1ebfb1d88e87f09f67a7df97e9a14dc717

Authored by m-holger
Committed by GitHub
2 parents a095549e 4ebe5452

Merge pull request #1503 from m-holger/fuzz

Fix linearization logic to conditionally add outlines object only if …
Showing 1 changed file with 13 additions and 7 deletions
libqpdf/QPDF_linearization.cc
@@ -1412,14 +1412,20 @@ QPDF::pushOutlinesToPart( @@ -1412,14 +1412,20 @@ QPDF::pushOutlinesToPart(
1412 QTC::TC( 1412 QTC::TC(
1413 "qpdf", 1413 "qpdf",
1414 "QPDF lin outlines in part", 1414 "QPDF lin outlines in part",
1415 - ((&part == (&m->part6)) ? 0  
1416 - : (&part == (&m->part9)) ? 1  
1417 - : 9999)); // can't happen  
1418 - m->c_outline_data.first_object = outlines_og.getObj();  
1419 - m->c_outline_data.nobjects = 1;  
1420 - lc_outlines.erase(outlines_og);  
1421 - part.push_back(outlines); 1415 + &part == &m->part6 ? 0
  1416 + : (&part == &m->part9) ? 1
  1417 + : 9999); // can't happen
  1418 + if (lc_outlines.erase(outlines_og)) {
  1419 + // Make sure outlines is in lc_outlines in case the file is damaged. in which case it may be
  1420 + // included in an earlier part.
  1421 + part.push_back(outlines);
  1422 + m->c_outline_data.first_object = outlines_og.getObj();
  1423 + m->c_outline_data.nobjects = 1;
  1424 + }
1422 for (auto const& og: lc_outlines) { 1425 for (auto const& og: lc_outlines) {
  1426 + if (!m->c_outline_data.first_object) {
  1427 + m->c_outline_data.first_object = og.getObj();
  1428 + }
1423 part.push_back(getObject(og)); 1429 part.push_back(getObject(og));
1424 ++m->c_outline_data.nobjects; 1430 ++m->c_outline_data.nobjects;
1425 } 1431 }