From 44be95cc1ba9caa8c85e05c5d5189b7983c143c4 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Thu, 24 Mar 2022 22:34:27 -0400 Subject: [PATCH] Fix crash when building history changes * Replace rarely hit asserts with defined nullptr checks when replacing references without a group * Fix #7603 * Replace TOTP history comparison with checking the actual TOTP output instead of a compiled string --- src/core/Entry.cpp | 4 +--- src/gui/entry/EntryHistoryModel.cpp | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 8ea308d10..a798033f4 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -1139,7 +1139,7 @@ QString Entry::resolveReferencePlaceholderRecursive(const QString& placeholder, // using format from http://keepass.info/help/base/fieldrefs.html at the time of writing QRegularExpressionMatch match = EntryAttributes::matchReference(placeholder); - if (!match.hasMatch()) { + if (!match.hasMatch() || !m_group || !m_group->database()) { return placeholder; } @@ -1149,8 +1149,6 @@ QString Entry::resolveReferencePlaceholderRecursive(const QString& placeholder, const EntryReferenceType searchInType = Entry::referenceType(searchIn); - Q_ASSERT(m_group); - Q_ASSERT(m_group->database()); const Entry* refEntry = m_group->database()->rootGroup()->findEntryBySearchTerm(searchText, searchInType); if (refEntry) { diff --git a/src/gui/entry/EntryHistoryModel.cpp b/src/gui/entry/EntryHistoryModel.cpp index beadce6f0..ac70c2e66 100644 --- a/src/gui/entry/EntryHistoryModel.cpp +++ b/src/gui/entry/EntryHistoryModel.cpp @@ -232,7 +232,7 @@ void EntryHistoryModel::calculateHistoryModifications() || curr->timeInfo().expiryTime() != compare->timeInfo().expiryTime()) { modifiedFields << tr("Expiration"); } - if (curr->totpSettingsString() != compare->totpSettingsString()) { + if (curr->totp() != compare->totp()) { modifiedFields << tr("TOTP"); } if (*curr->customData() != *compare->customData()) {