diff --git a/modules/io/src/mol/star_parser.cc b/modules/io/src/mol/star_parser.cc index 80043259b4df5fdf34ee81de6bf471696d03bc5a..4f559b195314451947fb0fde2f7290ea0467c4d4 100644 --- a/modules/io/src/mol/star_parser.cc +++ b/modules/io/src/mol/star_parser.cc @@ -550,6 +550,8 @@ void StarParser::Parse() case 'd': if (tline.length()>=5 && StringRef("data_", 5)==tline.substr(0, 5)) { this->ParseData(); + } else { + throw IOException("Missing 'data_' control structure"); } break; case 'g': diff --git a/modules/io/tests/test_star_parser.cc b/modules/io/tests/test_star_parser.cc index 6ff217b748c123770f789a2168d540be3f1ef94d..a8ed75451df4b03b97114fdb0971a82ce0b36d26 100644 --- a/modules/io/tests/test_star_parser.cc +++ b/modules/io/tests/test_star_parser.cc @@ -389,6 +389,13 @@ BOOST_AUTO_TEST_CASE(star_items_as_row) BOOST_TEST_MESSAGE(" done."); } +BOOST_AUTO_TEST_CASE(star_broken_data) +{ + std::ifstream s("testfiles/broken_data.cif"); + LoopTestParser star_p(s); + BOOST_CHECK_THROW(star_p.Parse(), IOException); +} + BOOST_AUTO_TEST_CASE(star_missing_data) { std::ifstream s("testfiles/missing_data.cif"); diff --git a/modules/io/tests/testfiles/broken_data.cif b/modules/io/tests/testfiles/broken_data.cif new file mode 100644 index 0000000000000000000000000000000000000000..2ae242255c2bd8c6e952ffee6d1815ee01f6335a --- /dev/null +++ b/modules/io/tests/testfiles/broken_data.cif @@ -0,0 +1 @@ +d lines starting with a 'd' kicked the parser into an infinite loop.