aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFObjectHandle.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-08-29 22:33:19 +0200
committerGitHub <noreply@github.com>2022-08-29 22:33:19 +0200
commit0adfd74f8b5dc96091cd0b4251b08401f54df2ed (patch)
tree9ff07be139c118dc5bf02f98afeda41162066bfc /libqpdf/QPDFObjectHandle.cc
parent2b01a79e876d60df7ec330a60cb213f3ecc3559f (diff)
parentc53d54b13dc6ad369646a09c64d392549effac38 (diff)
downloadqpdf-0adfd74f8b5dc96091cd0b4251b08401f54df2ed.tar.zst
Merge pull request #747 from m-holger/new_stream
Add optional parameter allow_nullptr to QPDFObjectHandle::getOwningQPDF
Diffstat (limited to 'libqpdf/QPDFObjectHandle.cc')
-rw-r--r--libqpdf/QPDFObjectHandle.cc27
1 files changed, 9 insertions, 18 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc
index cf5460d7..8a2d59e3 100644
--- a/libqpdf/QPDFObjectHandle.cc
+++ b/libqpdf/QPDFObjectHandle.cc
@@ -1207,14 +1207,6 @@ QPDFObjectHandle::getUniqueResourceName(
" QPDFObjectHandle::getUniqueResourceName");
}
-// Indirect object accessors
-QPDF*
-QPDFObjectHandle::getOwningQPDF()
-{
- // Will be null for direct objects
- return this->qpdf;
-}
-
// Dictionary mutators
void
@@ -1634,16 +1626,15 @@ QPDFObjectHandle::coalesceContentStreams()
// files may have pages that are invalid in other ways.
return;
}
- QPDF* qpdf = getOwningQPDF();
- if (qpdf == nullptr) {
- // Should not be possible for a page object to not have an
- // owning PDF unless it was manually constructed in some
- // incorrect way. However, it can happen in a PDF file whose
- // page structure is direct, which is against spec but still
- // possible to hand construct, as in fuzz issue 27393.
- throw std::runtime_error("coalesceContentStreams called on object"
- " with no associated PDF file");
- }
+ // Should not be possible for a page object to not have an
+ // owning PDF unless it was manually constructed in some
+ // incorrect way. However, it can happen in a PDF file whose
+ // page structure is direct, which is against spec but still
+ // possible to hand construct, as in fuzz issue 27393.
+ QPDF* qpdf = getOwningQPDF(
+ false,
+ "coalesceContentStreams called on object with no associated PDF file");
+
QPDFObjectHandle new_contents = newStream(qpdf);
this->replaceKey("/Contents", new_contents);