Commit ee7824cf28536b8acf5f47aa76ced348df5f6d35

Authored by Jay Berkenbilt
1 parent 021db6f2

QPDFJob: convert encryption_file args to shared pointers

include/qpdf/QPDFJob.hh
... ... @@ -208,8 +208,8 @@ class QPDFJob
208 208 bool suppress_warnings;
209 209 bool warnings_exit_zero;
210 210 bool copy_encryption;
211   - char const* encryption_file;
212   - char const* encryption_file_password;
  211 + std::string encryption_file;
  212 + std::shared_ptr<char> encryption_file_password;
213 213 bool encrypt;
214 214 bool password_is_hex_key;
215 215 bool suppress_password_recovery;
... ...
libqpdf/QPDFJob.cc
... ... @@ -327,7 +327,6 @@ QPDFJob::QPDFJob() :
327 327 suppress_warnings(false),
328 328 warnings_exit_zero(false),
329 329 copy_encryption(false),
330   - encryption_file(0),
331 330 encryption_file_password(0),
332 331 encrypt(false),
333 332 password_is_hex_key(false),
... ... @@ -2603,11 +2602,11 @@ QPDFJob::handlePageSpecs(
2603 2602 // to the same underlying file with the same path to
2604 2603 // achieve the same affect.
2605 2604 char const* password = page_spec.password;
2606   - if (o.encryption_file && (password == 0) &&
  2605 + if ((! o.encryption_file.empty()) && (password == 0) &&
2607 2606 (page_spec.filename == o.encryption_file))
2608 2607 {
2609 2608 QTC::TC("qpdf", "qpdf pages encryption password");
2610   - password = o.encryption_file_password;
  2609 + password = o.encryption_file_password.get();
2611 2610 }
2612 2611 o.doIfVerbose([&](std::ostream& cout, std::string const& prefix) {
2613 2612 cout << prefix << ": processing "
... ... @@ -3221,7 +3220,8 @@ QPDFJob::setWriterOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
3221 3220 if (o.copy_encryption)
3222 3221 {
3223 3222 std::shared_ptr<QPDF> encryption_pdf =
3224   - processFile(o.encryption_file, o.encryption_file_password);
  3223 + processFile(o.encryption_file.c_str(),
  3224 + o.encryption_file_password.get());
3225 3225 w.copyEncryptionParameters(*encryption_pdf);
3226 3226 }
3227 3227 if (o.encrypt)
... ...
libqpdf/QPDFJob_argv.cc
... ... @@ -347,7 +347,7 @@ ArgParser::argCopyEncryption(char* parameter)
347 347 void
348 348 ArgParser::argEncryptionFilePassword(char* parameter)
349 349 {
350   - o.encryption_file_password = parameter;
  350 + o.encryption_file_password = QUtil::make_shared_cstr(parameter);
351 351 }
352 352  
353 353 void
... ...