aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_json.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-20 15:14:52 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-20 15:16:25 +0200
commit6d4e3ba8a43d8a084a94f9cea4669cb35812fb67 (patch)
treebfd7f39fc4e61aa7e19300a9b497970faec32891 /libqpdf/QPDF_json.cc
parent5a2aa5947944a789164efc6555e32b79525487cf (diff)
downloadqpdf-6d4e3ba8a43d8a084a94f9cea4669cb35812fb67.tar.zst
Test (and fix) handling of dangling references
Diffstat (limited to 'libqpdf/QPDF_json.cc')
-rw-r--r--libqpdf/QPDF_json.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/libqpdf/QPDF_json.cc b/libqpdf/QPDF_json.cc
index b7fe4368..18631114 100644
--- a/libqpdf/QPDF_json.cc
+++ b/libqpdf/QPDF_json.cc
@@ -147,6 +147,7 @@ QPDF::JSONReactor::arrayStart()
void
QPDF::JSONReactor::containerEnd(JSON const& value)
{
+ auto from_state = state;
state = state_stack.back();
state_stack.pop_back();
if (state == st_initial) {
@@ -215,10 +216,13 @@ QPDF::JSONReactor::containerEnd(JSON const& value)
if (!parse_error) {
object_stack.pop_back();
}
- } else if (state == st_qpdf) {
+ } else if ((state == st_top) && (from_state == st_qpdf)) {
for (auto const& og: this->reserved) {
- // QXXXQ
- // QTC::TC("qpdf", "QPDF_json non-trivial null reserved");
+ // Handle dangling indirect object references which the
+ // PDF spec says to treat as nulls. It's tempting to make
+ // this an error, but that would be wrong since valid
+ // input files may have these.
+ QTC::TC("qpdf", "QPDF_json non-trivial null reserved");
this->pdf.replaceObject(og, QPDFObjectHandle::newNull());
}
this->reserved.clear();