From 31396f61c98ff955118f192f75bf02320c7a2abc Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 2 Sep 2022 09:37:17 -0400 Subject: Disallow --empty with --replace-input (fixes #728) --- libqpdf/QPDFJob.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 691f193c..8bf619a2 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -683,7 +683,13 @@ QPDFJob::getExitCode() const void QPDFJob::checkConfiguration() { + // Do final checks for command-line consistency. (I always think + // this is called doFinalChecks, so I'm putting that in a + // comment.) + if (m->replace_input) { + // Check for --empty appears later after we have checked + // m->infilename. if (m->outfilename) { usage("--replace-input may not be used when" " an output file is specified"); @@ -700,6 +706,8 @@ QPDFJob::checkConfiguration() } if (m->infilename == nullptr) { usage("an input file name is required"); + } else if (m->replace_input && (strlen(m->infilename.get()) == 0)) { + usage("--replace-input may not be used with --empty"); } else if ( m->require_outfile && (m->outfilename == nullptr) && (!m->replace_input)) { -- cgit v1.2.3-54-g00ecf