diff --git a/src/importexport/musicxml/internal/musicxml/importmxmlpass1.cpp b/src/importexport/musicxml/internal/musicxml/importmxmlpass1.cpp index 1d07e6014c2cc..0d081fe2ece00 100644 --- a/src/importexport/musicxml/internal/musicxml/importmxmlpass1.cpp +++ b/src/importexport/musicxml/internal/musicxml/importmxmlpass1.cpp @@ -788,7 +788,11 @@ static void inferFromTitle(String& title, String& inferredSubtitle, String& infe StringList subtitleLines; StringList creditLines; StringList titleLines = title.split(std::regex("\\n")); - for (size_t i = titleLines.size(); i > 1; --i) { + size_t nrOfTitleLines = titleLines.size(); + if (nrOfTitleLines == 1) { + return; + } + for (size_t i = nrOfTitleLines; i > 0; --i) { String line = titleLines[i - 1]; if (isLikelyCreditText(line, true)) { creditLines.insert(0, line);