diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-03 13:41:07 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-04 00:31:22 +0200 |
commit | 92b692466f7a4dbf4e51e6a77713c029a3e18ab1 (patch) | |
tree | ba139d7b9c290bfc2a83c2719cf0ce86cf27ad36 /libqpdf/QPDF_pages.cc | |
parent | b20f0519224b0c089f78730fb20291cc2d539979 (diff) | |
download | qpdf-92b692466f7a4dbf4e51e6a77713c029a3e18ab1.tar.zst |
Remove remaining incorrect assert calls from implementation
Diffstat (limited to 'libqpdf/QPDF_pages.cc')
-rw-r--r-- | libqpdf/QPDF_pages.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libqpdf/QPDF_pages.cc b/libqpdf/QPDF_pages.cc index 89a782f4..e8416b2b 100644 --- a/libqpdf/QPDF_pages.cc +++ b/libqpdf/QPDF_pages.cc @@ -1,7 +1,5 @@ #include <qpdf/QPDF.hh> -#include <assert.h> - #include <qpdf/QPDFExc.hh> #include <qpdf/QTC.hh> #include <qpdf/QUtil.hh> @@ -233,6 +231,11 @@ QPDF::insertPage(QPDFObjectHandle newpage, int pos) QTC::TC("qpdf", "QPDF insert indirect page"); } + if ((pos < 0) || (QIntC::to_size(pos) > this->m->all_pages.size())) { + throw std::runtime_error( + "QPDF::insertPage called with pos out of range"); + } + QTC::TC( "qpdf", "QPDF insert page", @@ -249,7 +252,6 @@ QPDF::insertPage(QPDFObjectHandle newpage, int pos) QPDFObjectHandle pages = getRoot().getKey("/Pages"); QPDFObjectHandle kids = pages.getKey("/Kids"); - assert((pos >= 0) && (QIntC::to_size(pos) <= this->m->all_pages.size())); newpage.replaceKey("/Parent", pages); kids.insertItem(pos, newpage); |