From 9380c41486790e777e1541543a17b360458eb6b4 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Thu, 23 Jan 2025 12:48:45 -0500 Subject: [PATCH] Check to add bonds of valid atoms Signed-off-by: Geoff Hutchison --- avogadro/io/pdbformat.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avogadro/io/pdbformat.cpp b/avogadro/io/pdbformat.cpp index 96d9cfafc3..f3379cc268 100644 --- a/avogadro/io/pdbformat.cpp +++ b/avogadro/io/pdbformat.cpp @@ -243,7 +243,8 @@ bool PdbFormat::read(std::istream& in, Core::Molecule& mol) b = b - terCount; b = rawToAtomId[b]; - if (a < b && a >= 0 && b >= 0) { + if (a < b && a >= 0 && b >= 0 && a < mol.atomCount() && + b < mol.atomCount()) { mol.Avogadro::Core::Molecule::addBond(a, b, 1); } }