From 4490d4c35e60f0acc1ff3b554a9e944aa5672f65 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 5 Jun 2023 20:10:15 +0100 Subject: Avoid unnecessary copying of stream dictionary in QPDF::readObject --- libqpdf/QPDF.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'libqpdf') 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 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()); -- cgit v1.2.3-54-g00ecf