From b0fa6b5e689d798779f6b068866e3cbd3ae7252a Mon Sep 17 00:00:00 2001 From: Stefan Forstenlechner Date: Wed, 26 Jun 2024 14:28:51 +0200 Subject: [PATCH] Handle possible nullptr exception --- share/translations/keepassxc_en.ts | 4 ++++ src/gui/DatabaseWidget.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/share/translations/keepassxc_en.ts b/share/translations/keepassxc_en.ts index f18073803..d862fbab4 100644 --- a/share/translations/keepassxc_en.ts +++ b/share/translations/keepassxc_en.ts @@ -2674,6 +2674,10 @@ Disable safe saves and try again? Do you want to remove the passkey from this entry? + + Could not upload the database. Remote handler was not initialized. + + EditEntryWidget diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 0302889fd..472e434f0 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1135,7 +1135,10 @@ void DatabaseWidget::syncDatabaseWithLockedDatabase(const QString& filePath, con void DatabaseWidget::uploadAndFinishSync(const RemoteParams* params, RemoteHandler::RemoteResult result) { - if (result.success && !params->uploadCommand.isEmpty()) { + if (!m_remoteHandler) { + result.success = false; + result.errorMessage = tr("Could not upload the database. Remote handler was not initialized."); + } else if (result.success && !params->uploadCommand.isEmpty()) { emit updateSyncProgress(75, tr("Uploading...")); result = m_remoteHandler->upload(params); }