Commit 021db6f226191e536a84ba6a76590bf5743d5d62
1 parent
1a8c2eb9
QPDFJob: convert password to shared pointer
Showing
3 changed files
with
4 additions
and
7 deletions
include/qpdf/QPDFJob.hh
| @@ -199,8 +199,7 @@ class QPDFJob | @@ -199,8 +199,7 @@ class QPDFJob | ||
| 199 | 199 | ||
| 200 | enum remove_unref_e { re_auto, re_yes, re_no }; | 200 | enum remove_unref_e { re_auto, re_yes, re_no }; |
| 201 | 201 | ||
| 202 | - char const* password; | ||
| 203 | - std::shared_ptr<char> password_alloc; | 202 | + std::shared_ptr<char> password; |
| 204 | bool linearize; | 203 | bool linearize; |
| 205 | bool decrypt; | 204 | bool decrypt; |
| 206 | int split_pages; | 205 | int split_pages; |
libqpdf/QPDFJob.cc
| @@ -452,7 +452,7 @@ QPDFJob::run() | @@ -452,7 +452,7 @@ QPDFJob::run() | ||
| 452 | std::shared_ptr<QPDF> pdf_ph; | 452 | std::shared_ptr<QPDF> pdf_ph; |
| 453 | try | 453 | try |
| 454 | { | 454 | { |
| 455 | - pdf_ph = processFile(o.infilename, o.password); | 455 | + pdf_ph = processFile(o.infilename, o.password.get()); |
| 456 | } | 456 | } |
| 457 | catch (QPDFExc& e) | 457 | catch (QPDFExc& e) |
| 458 | { | 458 | { |
libqpdf/QPDFJob_argv.cc
| @@ -178,7 +178,7 @@ ArgParser::argShowCrypto() | @@ -178,7 +178,7 @@ ArgParser::argShowCrypto() | ||
| 178 | void | 178 | void |
| 179 | ArgParser::argPassword(char* parameter) | 179 | ArgParser::argPassword(char* parameter) |
| 180 | { | 180 | { |
| 181 | - o.password = parameter; | 181 | + o.password = QUtil::make_shared_cstr(parameter); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | void | 184 | void |
| @@ -197,9 +197,7 @@ ArgParser::argPasswordFile(char* parameter) | @@ -197,9 +197,7 @@ ArgParser::argPasswordFile(char* parameter) | ||
| 197 | } | 197 | } |
| 198 | if (lines.size() >= 1) | 198 | if (lines.size() >= 1) |
| 199 | { | 199 | { |
| 200 | - // Make sure the memory for this stays in scope. | ||
| 201 | - o.password_alloc = QUtil::make_shared_cstr(lines.front()); | ||
| 202 | - o.password = o.password_alloc.get(); | 200 | + o.password = QUtil::make_shared_cstr(lines.front()); |
| 203 | 201 | ||
| 204 | if (lines.size() > 1) | 202 | if (lines.size() > 1) |
| 205 | { | 203 | { |