Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential crash in search if an entry doesn't have a group #9633

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/core/EntrySearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ bool EntrySearcher::searchEntryImpl(const Entry* entry)
auto attributes = QStringList(attributes_keys + entry->attributes()->values(attributes_keys));
auto attachments = QStringList(entry->attachments()->keys());
// Build a group hierarchy to allow searching for e.g. /group1/subgroup*
auto hierarchy = entry->group()->hierarchy().join('/').prepend("/");
QString hierarchy;
if (entry->group()) {
hierarchy = entry->group()->hierarchy().join('/').prepend("/");
}

// By default, empty term matches every entry.
// However when skipping protected fields, we will reject everything instead
Expand Down Expand Up @@ -190,7 +193,7 @@ bool EntrySearcher::searchEntryImpl(const Entry* entry)
// Match against the full hierarchy if the word contains a '/' otherwise just the group name
if (term.word.contains('/')) {
found = term.regex.match(hierarchy).hasMatch();
} else {
} else if (entry->group()) {
found = term.regex.match(entry->group()->name()).hasMatch();
}
break;
Expand Down