diff options
author | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2023-06-17 16:54:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-17 16:54:45 +0200 |
commit | d3c444a7fb7ef62d44633cba4ab433348bc27943 (patch) | |
tree | 77557e423b25698608d5383131488e7ac1cc5bd2 /libqpdf | |
parent | 44dce4e2988ec09e36dfb6d1fc527a143e6f597f (diff) | |
parent | 4490d4c35e60f0acc1ff3b554a9e944aa5672f65 (diff) | |
download | qpdf-d3c444a7fb7ef62d44633cba4ab433348bc27943.tar.zst |
Merge pull request #980 from m-holger/readobject
Avoid unnecessary copying of stream dictionary in QPDF::readObject
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDF.cc | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 6f718742..734ab858 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1343,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()); |