Correct a segfault in encfsctl (#498)

The context must remain and not die just after init.
Introduced in dcf8435d4c.
This commit is contained in:
Ben RUBSON 2018-03-25 23:04:34 +02:00 committed by GitHub
parent 2a24884ff0
commit b80d30755c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,6 +115,8 @@ struct CommandOpts {
gettext_noop(" -- print version number and exit")},
{0, 0, 0, 0, 0, 0}};
auto ctx = std::make_shared<EncFS_Context>();
static void usage(const char *name) {
cerr << autosprintf(_("encfsctl version %s"), VERSION) << "\n"
<< _("Usage:\n")
@ -252,7 +254,6 @@ static RootPtr initRootInfo(int &argc, char **&argv) {
--argc;
++argv;
auto ctx = std::make_shared<EncFS_Context>();
ctx->publicFilesystem = opts->ownerCreate;
if (checkDir(opts->rootDir)) result = initFS(ctx.get(), opts);
@ -273,7 +274,6 @@ static RootPtr initRootInfo(const char *crootDir) {
opts->createIfNotFound = false;
opts->checkKey = false;
auto ctx = std::make_shared<EncFS_Context>();
ctx->publicFilesystem = opts->ownerCreate;
result = initFS(ctx.get(), opts);
}