aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc33
1 files changed, 14 insertions, 19 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 64ff4715..396dfe8f 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -106,9 +106,8 @@ namespace
throwException()
{
throw std::logic_error("QPDF operation attempted on a QPDF object with no input "
- "source."
- " QPDF operations are invalid before processFile (or another"
- " process method) or after closeInputSource");
+ "source. QPDF operations are invalid before processFile (or "
+ "another process method) or after closeInputSource");
}
};
} // namespace
@@ -841,7 +840,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
}
if (type == 'f') {
// Save deleted items until after we've checked the XRefStm, if any.
- deleted_items.push_back(QPDFObjGen(toI(i), f2));
+ deleted_items.emplace_back(toI(i), f2);
} else {
insertXrefEntry(toI(i), 1, f1, f2);
}
@@ -1344,21 +1343,16 @@ QPDF::readObject(
size_t length = 0;
try {
- std::map<std::string, QPDFObjectHandle> dict = object.getDictAsMap();
+ auto length_obj = object.getKey("/Length");
- if (dict.count("/Length") == 0) {
- QTC::TC("qpdf", "QPDF stream without length");
- throw damagedPDF(input, offset, "stream dictionary lacks /Length key");
- }
-
- QPDFObjectHandle length_obj = dict["/Length"];
if (!length_obj.isInteger()) {
+ if (length_obj.isNull()) {
+ QTC::TC("qpdf", "QPDF stream without length");
+ throw damagedPDF(input, offset, "stream dictionary lacks /Length key");
+ }
QTC::TC("qpdf", "QPDF stream length not integer");
throw damagedPDF(
- input,
- offset,
- "/Length key in stream dictionary is not "
- "an integer");
+ input, offset, "/Length key in stream dictionary is not an integer");
}
length = toS(length_obj.getUIntValue());
@@ -1488,7 +1482,8 @@ QPDF::readObjectAtOffset(
// Special case: if offset is 0, just return null. Some PDF writers, in particular
// "Mac OS X 10.7.5 Quartz PDFContext", may store deleted objects in the xref table as
- // "0000000000 00000 n", which is not correct, but it won't hurt anything for to ignore these.
+ // "0000000000 00000 n", which is not correct, but it won't hurt anything for us to ignore
+ // these.
if (offset == 0) {
QTC::TC("qpdf", "QPDF bogus 0 offset", 0);
warn(damagedPDF(0, "object has offset 0"));
@@ -2213,7 +2208,7 @@ QPDF::getVersionAsPDFVersion()
minor = QUtil::string_to_int(match[2].str().c_str());
}
- return PDFVersion(major, minor, extension_level);
+ return {major, minor, extension_level};
}
std::string
@@ -2484,7 +2479,7 @@ QPDF::damagedPDF(
qpdf_offset_t offset,
std::string const& message)
{
- return QPDFExc(qpdf_e_damaged_pdf, input->getName(), object, offset, message);
+ return {qpdf_e_damaged_pdf, input->getName(), object, offset, message};
}
// Return an exception of type qpdf_e_damaged_pdf. The object is taken from
@@ -2500,7 +2495,7 @@ QPDF::damagedPDF(
QPDFExc
QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message)
{
- return QPDFExc(qpdf_e_damaged_pdf, m->file->getName(), object, offset, message);
+ return {qpdf_e_damaged_pdf, m->file->getName(), object, offset, message};
}
// Return an exception of type qpdf_e_damaged_pdf. The filename is taken from m->file and the