From 11bff12d49e347e3dc34c6f318fd8548556977aa Mon Sep 17 00:00:00 2001 From: Makiah Bennett Date: Sun, 3 Dec 2023 19:13:19 -0600 Subject: [PATCH] Avoid segfaulting while manipulating carbon bonds and associated hydrogens Signed-off-by: Makiah Bennett --- avogadro/qtgui/hydrogentools.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/avogadro/qtgui/hydrogentools.cpp b/avogadro/qtgui/hydrogentools.cpp index 3187889dbf..b7b5266b2d 100644 --- a/avogadro/qtgui/hydrogentools.cpp +++ b/avogadro/qtgui/hydrogentools.cpp @@ -134,6 +134,9 @@ void HydrogenTools::adjustHydrogens(RWAtom& atom, Adjustment adjustment) // convenience RWMolecule* molecule = atom.molecule(); + if (molecule == nullptr) + return; + if (doRemove) { // get the list of hydrogens connected to this std::vector badHIndices;