2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-29 16:30:53 +00:00

QPDFJob: convert encryption_file args to shared pointers

This commit is contained in:
Jay Berkenbilt 2022-01-22 17:53:57 -05:00
parent 021db6f226
commit ee7824cf28
3 changed files with 7 additions and 7 deletions

View File

@ -208,8 +208,8 @@ class QPDFJob
bool suppress_warnings;
bool warnings_exit_zero;
bool copy_encryption;
char const* encryption_file;
char const* encryption_file_password;
std::string encryption_file;
std::shared_ptr<char> encryption_file_password;
bool encrypt;
bool password_is_hex_key;
bool suppress_password_recovery;

View File

@ -327,7 +327,6 @@ QPDFJob::QPDFJob() :
suppress_warnings(false),
warnings_exit_zero(false),
copy_encryption(false),
encryption_file(0),
encryption_file_password(0),
encrypt(false),
password_is_hex_key(false),
@ -2603,11 +2602,11 @@ QPDFJob::handlePageSpecs(
// to the same underlying file with the same path to
// achieve the same affect.
char const* password = page_spec.password;
if (o.encryption_file && (password == 0) &&
if ((! o.encryption_file.empty()) && (password == 0) &&
(page_spec.filename == o.encryption_file))
{
QTC::TC("qpdf", "qpdf pages encryption password");
password = o.encryption_file_password;
password = o.encryption_file_password.get();
}
o.doIfVerbose([&](std::ostream& cout, std::string const& prefix) {
cout << prefix << ": processing "
@ -3221,7 +3220,8 @@ QPDFJob::setWriterOptions(QPDF& pdf, QPDFWriter& w)
if (o.copy_encryption)
{
std::shared_ptr<QPDF> encryption_pdf =
processFile(o.encryption_file, o.encryption_file_password);
processFile(o.encryption_file.c_str(),
o.encryption_file_password.get());
w.copyEncryptionParameters(*encryption_pdf);
}
if (o.encrypt)

View File

@ -347,7 +347,7 @@ ArgParser::argCopyEncryption(char* parameter)
void
ArgParser::argEncryptionFilePassword(char* parameter)
{
o.encryption_file_password = parameter;
o.encryption_file_password = QUtil::make_shared_cstr(parameter);
}
void