From b9cd693a5b36b8b0246822cb97386792045179ec Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 22 Jan 2022 18:57:01 -0500 Subject: QPDFJob: allocate QPDFArgParser on stack The previous commits have removed all references to memory from QPDFArgParser from QPDFJob. This commit removes the constraint that QPDFArgParser remain in scope. This is a prerequisite to allowing JSON as an alternative way to initialize QPDFJob and to initialize it directly using a public API. --- libqpdf/QPDFJob_argv.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc index 316beda0..8da5e836 100644 --- a/libqpdf/QPDFJob_argv.cc +++ b/libqpdf/QPDFJob_argv.cc @@ -1529,11 +1529,8 @@ QPDFJob::initializeFromArgv(int argc, char* argv[], char const* progname_env) { progname_env = "QPDF_EXECUTABLE"; } - // QPDFArgParser must stay in scope for the life of the QPDFJob - // object since it holds dynamic memory used for argv, which is - // pointed to by other member variables. - this->m->ap = std::make_shared(argc, argv, progname_env); - setMessagePrefix(this->m->ap->getProgname()); - ArgParser ap(*this->m->ap, *this); + QPDFArgParser qap(argc, argv, progname_env); + setMessagePrefix(qap.getProgname()); + ArgParser ap(qap, *this); ap.parseOptions(); } -- cgit v1.2.3-70-g09d2