aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libqpdf/QPDFJob_config.cc3
-rw-r--r--qpdf/qtest/page-labels.test4
2 files changed, 5 insertions, 2 deletions
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index e9084e85..107abf7c 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -1139,6 +1139,9 @@ QPDFJob::Config::setPageLabels(const std::vector<std::string>& specs)
}
auto start_num = match[3].matched ? QUtil::string_to_int(match[3].str().c_str()) : 1;
+ if (start_num < 1) {
+ usage("starting page number must be >= 1");
+ }
auto prefix = match[4].matched ? match[4].str() : "";
// We can't check ordering until we know how many pages there are, so that is delayed until
// near the end.
diff --git a/qpdf/qtest/page-labels.test b/qpdf/qtest/page-labels.test
index 9927437b..b90acd61 100644
--- a/qpdf/qtest/page-labels.test
+++ b/qpdf/qtest/page-labels.test
@@ -33,8 +33,8 @@ $td->runtest("no page labels",
my @errors = (
["quack", ".*page label spec must be.*"],
["5:r 10:D", ".*the first page .*must start with page 1.*"],
- ["1:r 10:D 31:A",
- ".*page 31 is more than the total number of pages \\(30\\).*"],
+ ["1:r 10:D 31:A", ".*page 31 is more than the total number of pages \\(30\\).*"],
+ ["1:r/0", ".*starting page number must be >= 1.*"],
);
$n_tests += scalar(@errors);