diff --git a/src/cli/keepassxc-cli.cpp b/src/cli/keepassxc-cli.cpp index 98cc6be06a..179b79a435 100644 --- a/src/cli/keepassxc-cli.cpp +++ b/src/cli/keepassxc-cli.cpp @@ -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); @@ -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)