Skip to content

Commit

Permalink
Fix crash upon exiting interactive mode if there is no current database.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjamesr authored and droidmonkey committed Dec 21, 2019
1 parent 794cc1e commit dcb092b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cli/keepassxc-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ void enterInteractiveMode(const QStringList& arguments)
prompt += "> ";
command = reader->readLine(prompt);
if (reader->isFinished()) {
currentDatabase->releaseData();
return;
break;
}

QStringList args = Utils::splitCommandString(command);
Expand All @@ -163,14 +162,17 @@ void enterInteractiveMode(const QStringList& arguments)
errorTextStream << QObject::tr("Unknown command %1").arg(args[0]) << "\n";
continue;
} else if (cmd->name == "quit" || cmd->name == "exit") {
currentDatabase->releaseData();
return;
break;
}

cmd->currentDatabase = currentDatabase;
cmd->execute(args);
currentDatabase = cmd->currentDatabase;
}

if (currentDatabase) {
currentDatabase->releaseData();
}
}

int main(int argc, char** argv)
Expand Down

0 comments on commit dcb092b

Please sign in to comment.