diff --git a/modules/io/src/mol/star_parser.cc b/modules/io/src/mol/star_parser.cc index 4f559b195314451947fb0fde2f7290ea0467c4d4..214eb626c9f743a1cbbb218bede0ad7f795b2f73 100644 --- a/modules/io/src/mol/star_parser.cc +++ b/modules/io/src/mol/star_parser.cc @@ -557,6 +557,8 @@ void StarParser::Parse() case 'g': if (tline.length()>=7 && StringRef("global_", 7)==tline.substr(0, 7)) { this->ParseGlobal(); + } else { + throw IOException("Missing 'global_' control structure"); } break; case '#': diff --git a/modules/io/tests/test_star_parser.cc b/modules/io/tests/test_star_parser.cc index a8ed75451df4b03b97114fdb0971a82ce0b36d26..c4e40fdbda137d74293282a592884fb5aa7e8305 100644 --- a/modules/io/tests/test_star_parser.cc +++ b/modules/io/tests/test_star_parser.cc @@ -396,6 +396,13 @@ BOOST_AUTO_TEST_CASE(star_broken_data) BOOST_CHECK_THROW(star_p.Parse(), IOException); } +BOOST_AUTO_TEST_CASE(star_broken_global) +{ + std::ifstream s("testfiles/broken_global.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_global.cif b/modules/io/tests/testfiles/broken_global.cif new file mode 100644 index 0000000000000000000000000000000000000000..0f340e0befe0077229b53b121979181ec3c890fc --- /dev/null +++ b/modules/io/tests/testfiles/broken_global.cif @@ -0,0 +1 @@ +g lines starting with a 'g' kicked the parser into an infinite loop.