Skip to content

Commit

Permalink
Fix a segfault when searching for an atom that doesn't exist, from a …
Browse files Browse the repository at this point in the history
…molecule editor

(or anything that isn't re-wrapped)
  • Loading branch information
chryswoods committed Feb 8, 2023
1 parent 46f9779 commit 7483121
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion corelib/src/libs/SireMol/moleculeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,17 @@ Atom MoleculeView::atom(const QString &name, const PropertyMap &map) const
{
try
{
auto a = this->search(name).views().at(0).atom();
auto matches = this->search(name).views();

if (matches.isEmpty())
{
throw SireMol::missing_atom(QObject::tr(
"No atom matches '%1'")
.arg(name),
CODELOC);
}

auto a = matches.at(0).atom();
return this->atom(a.index(), map);
}
catch (...)
Expand Down

0 comments on commit 7483121

Please sign in to comment.