aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_Stream.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-02-16 23:25:27 +0100
committerJay Berkenbilt <ejb@ql.org>2018-02-19 03:06:27 +0100
commitd0e99f195a987c483bbb6c5449cf39bee34e08a1 (patch)
treecead8acd60cd14fd5d904ed380c750540cb361f3 /libqpdf/QPDF_Stream.cc
parentc2e16827b69f3d3ac3721cfcd608b87f28e2a13f (diff)
downloadqpdf-d0e99f195a987c483bbb6c5449cf39bee34e08a1.tar.zst
More robust handling of type errors
Give objects descriptions and context so it is possible to issue warnings instead of fatal errors for attempts to access objects of the wrong type.
Diffstat (limited to 'libqpdf/QPDF_Stream.cc')
-rw-r--r--libqpdf/QPDF_Stream.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc
index 7b84d10c..384652e2 100644
--- a/libqpdf/QPDF_Stream.cc
+++ b/libqpdf/QPDF_Stream.cc
@@ -39,6 +39,7 @@ QPDF_Stream::QPDF_Stream(QPDF* qpdf, int objid, int generation,
"stream object instantiated with non-dictionary "
"object for dictionary");
}
+ setStreamDescription();
}
QPDF_Stream::~QPDF_Stream()
@@ -85,6 +86,35 @@ QPDF_Stream::getTypeName() const
return "stream";
}
+void
+QPDF_Stream::setDescription(QPDF* qpdf, std::string const& description)
+{
+ this->QPDFObject::setDescription(qpdf, description);
+ setDictDescription();
+}
+
+void
+QPDF_Stream::setStreamDescription()
+{
+ setDescription(
+ this->qpdf,
+ "stream object " + QUtil::int_to_string(this->objid) + " " +
+ QUtil::int_to_string(this->generation));
+}
+
+void
+QPDF_Stream::setDictDescription()
+{
+ QPDF* qpdf = 0;
+ std::string description;
+ if ((! this->stream_dict.hasObjectDescription()) &&
+ getDescription(qpdf, description))
+ {
+ this->stream_dict.setObjectDescription(
+ qpdf, description + " -> stream dictionary");
+ }
+}
+
QPDFObjectHandle
QPDF_Stream::getDict() const
{
@@ -688,6 +718,7 @@ void
QPDF_Stream::replaceDict(QPDFObjectHandle new_dict)
{
this->stream_dict = new_dict;
+ setDictDescription();
QPDFObjectHandle length_obj = new_dict.getKey("/Length");
if (length_obj.isInteger())
{