aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_pages.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2013-10-05 22:37:27 +0200
committerJay Berkenbilt <ejb@ql.org>2013-10-10 02:57:14 +0200
commite19eb579b221ade503d7d1ff0a6511d289863785 (patch)
tree8e0d330ff9d4132eadacc399affb7bcb1a1b5933 /libqpdf/QPDF_pages.cc
parent0bfe9024893ebb1f62108fe6c24410e6ba589c3e (diff)
downloadqpdf-e19eb579b221ade503d7d1ff0a6511d289863785.tar.zst
Replace some assertions with std::logic_error
Ideally, the library should never call assert outside of test code, but it does in several places. For some cases where the assertion might conceivably fail because of a problem with the input data, replace assertions with exceptions so that they can be trapped by the calling application. This commit surely misses some cases and replaced some cases unnecessarily, but it should still be an improvement.
Diffstat (limited to 'libqpdf/QPDF_pages.cc')
-rw-r--r--libqpdf/QPDF_pages.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc
index 0604cd40..b88ed5fa 100644
--- a/libqpdf/QPDF_pages.cc
+++ b/libqpdf/QPDF_pages.cc
@@ -120,7 +120,10 @@ QPDF::flattenPagesTree()
pages.replaceKey("/Kids", QPDFObjectHandle::newArray(this->all_pages));
// /Count has not changed
- assert(pages.getKey("/Count").getIntValue() == len);
+ if (pages.getKey("/Count").getIntValue() != len)
+ {
+ throw std::logic_error("/Count is wrong after flattening pages tree");
+ }
}
void