From 07bb5c3dd6213af9c9a64e17ae2d457cf4fc7190 Mon Sep 17 00:00:00 2001 From: m-holger Date: Fri, 17 Feb 2023 14:59:33 +0000 Subject: Overload QPDF_Null::create to take a child object description --- libqpdf/QPDFObjectHandle.cc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'libqpdf/QPDFObjectHandle.cc') diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index cbe42995..d474dcce 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -802,12 +802,10 @@ QPDFObjectHandle::getArrayNItems() QPDFObjectHandle QPDFObjectHandle::getArrayItem(int n) { - QPDFObjectHandle result; auto array = asArray(); if (array && (n < array->getNItems()) && (n >= 0)) { - result = array->getItem(n); + return array->getItem(n); } else { - result = newNull(); if (array) { objectWarning("returning null for out of bounds array access"); QTC::TC("qpdf", "QPDFObjectHandle array bounds"); @@ -817,9 +815,8 @@ QPDFObjectHandle::getArrayItem(int n) } static auto constexpr msg = " -> null returned from invalid array access"sv; - result.obj->setChildDescription(obj, msg, ""); + return QPDF_Null::create(obj, msg, ""); } - return result; } bool @@ -1028,19 +1025,15 @@ QPDFObjectHandle::hasKey(std::string const& key) QPDFObjectHandle QPDFObjectHandle::getKey(std::string const& key) { - QPDFObjectHandle result; - auto dict = asDictionary(); - if (dict) { - result = dict->getKey(key); + if (auto dict = asDictionary()) { + return dict->getKey(key); } else { typeWarning("dictionary", "returning null for attempted key retrieval"); QTC::TC("qpdf", "QPDFObjectHandle dictionary null for getKey"); - result = newNull(); static auto constexpr msg = " -> null returned from getting key $VD from non-Dictionary"sv; - result.obj->setChildDescription(obj, msg, key); + return QPDF_Null::create(obj, msg, ""); } - return result; } QPDFObjectHandle -- cgit v1.2.3-70-g09d2