aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2024-01-09 14:35:10 +0100
committerJay Berkenbilt <ejb@ql.org>2024-01-10 12:49:31 +0100
commit20a134826c6f33fab81b0cdb9ba2d75fb03d1b59 (patch)
tree21cb545861a09435dab3c91156ab23a175f27be5 /libqpdf
parent8b0ae8bb99e377979e692dea8d8de579dab64af5 (diff)
downloadqpdf-20a134826c6f33fab81b0cdb9ba2d75fb03d1b59.tar.zst
Fix arg parsing check with --collate
The check for the number of items was in the wrong place.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFJob.cc4
-rw-r--r--libqpdf/QPDFJob_config.cc5
2 files changed, 4 insertions, 5 deletions
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index 2e0abb43..3bdb4f39 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -2446,6 +2446,10 @@ QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_hea
auto n_collate = m->collate.size();
auto n_specs = parsed_specs.size();
+ if (!(n_collate == 0 || n_collate == 1 || n_collate == n_specs)) {
+ usage("--pages: if --collate has more than one value, it must have one value per page "
+ "specification");
+ }
if (n_collate > 0 && n_specs > 1) {
// Collate the pages by selecting one page from each spec in order. When a spec runs out of
// pages, stop selecting from it.
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index e48d7e31..db6c5948 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -957,11 +957,6 @@ QPDFJob::PagesConfig::endPages()
if (n_specs == 0) {
usage("--pages: no page specifications given");
}
- auto n_collate = config->o.m->collate.size();
- if (!(n_collate == 0 || n_collate == 1 || n_collate == n_specs)) {
- usage("--pages: if --collate has more than one value, it must have one value per page "
- "specification");
- }
return this->config;
}