From 92b7c23b19fc4450f4d4153e0c35d878db00d502 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Sat, 2 Mar 2024 16:44:51 -0500 Subject: [PATCH] Fix crash with short TER record Fixes #1637 Signed-off-by: Geoff Hutchison --- avogadro/io/pdbformat.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/avogadro/io/pdbformat.cpp b/avogadro/io/pdbformat.cpp index 190ac45a11..cf7b839e04 100644 --- a/avogadro/io/pdbformat.cpp +++ b/avogadro/io/pdbformat.cpp @@ -191,8 +191,9 @@ bool PdbFormat::read(std::istream& in, Core::Molecule& mol) } } - else if (startsWith(buffer, "TER")) { // This is very important, each TER - // record also counts in the serial. + else if (startsWith(buffer, "TER") && + buffer.length() >= 11) { // This is very important, each TER + // record also counts in the serial. // Need to account for that when comparing with CONECT terList.push_back(lexicalCast(buffer.substr(6, 5), ok));