From c3a3a7f996bd5b7749eef960a0218751e3e0c195 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavier.robin@unibas.ch>
Date: Mon, 22 Jul 2024 18:45:42 +0200
Subject: [PATCH] fix: only read multiple data blocks in fault_tolerant mode

---
 modules/io/src/mol/mmcif_reader.cc | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc
index 64d632755..c307a22a2 100644
--- a/modules/io/src/mol/mmcif_reader.cc
+++ b/modules/io/src/mol/mmcif_reader.cc
@@ -99,6 +99,18 @@ bool MMCifReader::OnBeginData(const StringRef& data_name)
 {
   LOG_DEBUG("MCIFFReader: " << profile_);
   Profile profile_import("MMCifReader::OnBeginData");
+  if (chain_count_ > 0) {
+      std::stringstream ss;
+      ss << "Can only read one data block. Found second one 'data_" << data_name << "'.";
+      if (profile_.fault_tolerant) {
+        LOG_WARNING(ss.str());
+      } else {
+        throw IOException(this->FormatDiagnostic(STAR_DIAG_ERROR,
+                                                 ss.str(),
+                                                 this->GetCurrentLinenum()));
+      }
+
+  }
 
   // IDs in mmCIF files can be any string, so no restrictions here
 
-- 
GitLab