Commit 7bc52c5728591674f864ce7ff10c4bbe24787333

Authored by Jay Berkenbilt
1 parent 072623d6

set page labels: detect start page < 1 (fixes #939)

libqpdf/QPDFJob_config.cc
... ... @@ -1139,6 +1139,9 @@ QPDFJob::Config::setPageLabels(const std::vector&lt;std::string&gt;&amp; specs)
1139 1139 }
1140 1140  
1141 1141 auto start_num = match[3].matched ? QUtil::string_to_int(match[3].str().c_str()) : 1;
  1142 + if (start_num < 1) {
  1143 + usage("starting page number must be >= 1");
  1144 + }
1142 1145 auto prefix = match[4].matched ? match[4].str() : "";
1143 1146 // We can't check ordering until we know how many pages there are, so that is delayed until
1144 1147 // near the end.
... ...
qpdf/qtest/page-labels.test
... ... @@ -33,8 +33,8 @@ $td-&gt;runtest(&quot;no page labels&quot;,
33 33 my @errors = (
34 34 ["quack", ".*page label spec must be.*"],
35 35 ["5:r 10:D", ".*the first page .*must start with page 1.*"],
36   - ["1:r 10:D 31:A",
37   - ".*page 31 is more than the total number of pages \\(30\\).*"],
  36 + ["1:r 10:D 31:A", ".*page 31 is more than the total number of pages \\(30\\).*"],
  37 + ["1:r/0", ".*starting page number must be >= 1.*"],
38 38 );
39 39 $n_tests += scalar(@errors);
40 40  
... ...