aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-06-05 21:10:15 +0200
committerm-holger <m-holger@kubitscheck.org>2023-06-05 22:22:40 +0200
commit4490d4c35e60f0acc1ff3b554a9e944aa5672f65 (patch)
tree10a9bb689ea183f85bcc96d72b6ae5ebaaf437d2 /libqpdf/QPDF.cc
parent6e6a73d28f5f61f038209a61a3e85995dc71aa32 (diff)
downloadqpdf-4490d4c35e60f0acc1ff3b554a9e944aa5672f65.tar.zst
Avoid unnecessary copying of stream dictionary in QPDF::readObject
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc17
1 files changed, 6 insertions, 11 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 64ff4715..ebb5ff30 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -1344,21 +1344,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());