From 8539f5441fe274f97302f86f3327fc73c4794fb4 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sun, 15 Nov 2026 08:08:33 +0100 Subject: [PATCH] Restraint dictionary: an entry with bonds without lengths and no block of its own is refused, not dereferenced ReadRestraintDictionary looked up the block / comp_ of a CCD-style entry and used it without checking it was found; a user file naming its block otherwise crashed. It is now refused with the file name, like the other unreadable dictionaries. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK --- image_analysis/structure_refinement/MonomerLibrary.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/image_analysis/structure_refinement/MonomerLibrary.cpp b/image_analysis/structure_refinement/MonomerLibrary.cpp index 593c4699a..5c7f7ee09 100644 --- a/image_analysis/structure_refinement/MonomerLibrary.cpp +++ b/image_analysis/structure_refinement/MonomerLibrary.cpp @@ -164,6 +164,9 @@ void ReadRestraintDictionary(const std::string &text, const std::string &name, R gemmi::cif::Block *block = doc.find_block(code); if (block == nullptr) block = doc.find_block("comp_" + code); + if (block == nullptr) + throw std::runtime_error(name + ": no data block " + code + " or comp_" + code + " with the " + "coordinates of its bonds without lengths"); try { RestrainToCoordinates(cc, *block); } catch (const std::exception &e) {