Commit 570db9b60b64b91d875f1b838826a7b2e21079b4

Authored by Jay Berkenbilt
1 parent b43a0ac2

Catch more exceptions while resolving objects

Showing 1 changed file with 14 additions and 1 deletions
libqpdf/QPDF.cc
... ... @@ -1542,6 +1542,7 @@ QPDF::resolve(int objid, int generation)
1542 1542 }
1543 1543  
1544 1544 QPDFXRefEntry const& entry = this->xref_table[og];
  1545 + bool success = false;
1545 1546 try
1546 1547 {
1547 1548 switch (entry.getType())
... ... @@ -1569,11 +1570,23 @@ QPDF::resolve(int objid, int generation)
1569 1570 QUtil::int_to_string(generation) +
1570 1571 " has unexpected xref entry type");
1571 1572 }
  1573 + success = true;
1572 1574 }
1573 1575 catch (QPDFExc& e)
1574 1576 {
1575   - QTC::TC("qpdf", "QPDF resolve failure to null");
1576 1577 warn(e);
  1578 + }
  1579 + catch (std::exception& e)
  1580 + {
  1581 + warn(QPDFExc(qpdf_e_damaged_pdf, this->file->getName(), "", 0,
  1582 + "object " +
  1583 + QUtil::int_to_string(objid) + "/" +
  1584 + QUtil::int_to_string(generation) +
  1585 + ": error reading object: " + e.what()));
  1586 + }
  1587 + if (! success)
  1588 + {
  1589 + QTC::TC("qpdf", "QPDF resolve failure to null");
1577 1590 QPDFObjectHandle oh = QPDFObjectHandle::newNull();
1578 1591 this->obj_cache[og] =
1579 1592 ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
... ...