Skip to content

Commit

Permalink
Fix crash in KeeShare when importing deleted share
Browse files Browse the repository at this point in the history
* Fix keepassxreboot#4895 - when KeeShare imports a database it performs a merge operation. If that share was deleted from another identical database (ie, same base group UUID), then the group would be deleted in the middle of reinit causing a crash. This fix moves the group into a QPointer catching the delete operation.
  • Loading branch information
droidmonkey committed Oct 13, 2020
1 parent 1ed5cc9 commit dc57025
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/keeshare/ShareObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void ShareObserver::deinitialize()

void ShareObserver::reinitialize()
{
QList<QPair<Group*, KeeShareSettings::Reference>> shares;
QList<QPair<QPointer<Group>, KeeShareSettings::Reference>> shares;
for (Group* group : m_db->rootGroup()->groupsRecursive(true)) {
auto oldReference = m_groupToReference.value(group);
auto newReference = KeeShare::referenceOf(group);
Expand Down Expand Up @@ -97,6 +97,10 @@ void ShareObserver::reinitialize()
for (const auto& share : shares) {
auto group = share.first;
auto& reference = share.second;
// Check group validity, it may have been deleted by a merge action
if (!group) {
continue;
}

if (!reference.path.isEmpty() && reference.type != KeeShareSettings::Inactive) {
const auto newResolvedPath = resolvePath(reference.path, m_db);
Expand Down

0 comments on commit dc57025

Please sign in to comment.