2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-23 07:08:30 +00:00

QPDFJob: convert password to shared pointer

This commit is contained in:
Jay Berkenbilt 2022-01-22 17:51:47 -05:00
parent 1a8c2eb93b
commit 021db6f226
3 changed files with 4 additions and 7 deletions

View File

@ -199,8 +199,7 @@ class QPDFJob
enum remove_unref_e { re_auto, re_yes, re_no }; enum remove_unref_e { re_auto, re_yes, re_no };
char const* password; std::shared_ptr<char> password;
std::shared_ptr<char> password_alloc;
bool linearize; bool linearize;
bool decrypt; bool decrypt;
int split_pages; int split_pages;

View File

@ -452,7 +452,7 @@ QPDFJob::run()
std::shared_ptr<QPDF> pdf_ph; std::shared_ptr<QPDF> pdf_ph;
try try
{ {
pdf_ph = processFile(o.infilename, o.password); pdf_ph = processFile(o.infilename, o.password.get());
} }
catch (QPDFExc& e) catch (QPDFExc& e)
{ {

View File

@ -178,7 +178,7 @@ ArgParser::argShowCrypto()
void void
ArgParser::argPassword(char* parameter) ArgParser::argPassword(char* parameter)
{ {
o.password = parameter; o.password = QUtil::make_shared_cstr(parameter);
} }
void void
@ -197,9 +197,7 @@ ArgParser::argPasswordFile(char* parameter)
} }
if (lines.size() >= 1) if (lines.size() >= 1)
{ {
// Make sure the memory for this stays in scope. o.password = QUtil::make_shared_cstr(lines.front());
o.password_alloc = QUtil::make_shared_cstr(lines.front());
o.password = o.password_alloc.get();
if (lines.size() > 1) if (lines.size() > 1)
{ {