[MusicXML import] crash when importing single staff part referring to staff 2

• Mar 2, 2018 - 19:56
Reported version
2.2
Type
Functional
Severity
S2 - Critical
Status
closed
Project

Comments

In the case at hand, would it help to test for cr to be non null at the beginning of MusicXMLParserPass2::notations ? or there is a more involved problem?

Testing for cr to be non null at the beginning of MusicXMLParserPass2::notations and skipping the notations element would probably prevent the crash. The fact that cr can be null at all at that point is obviously a coding error, although it is a bit of a corner case caused by invalid input.

The real issue is in the "Bug fix for Cubase 6.5.5" when handling the staff element in MusicXMLParserPass2::note(), where any staff number greater than the number of staves in the part gets reset to staff 1. This leads to overlapping notes, which (due to missing or incorrect error handling) leads to the nullptr access.

Possible fixes could be:
- ignore anything with a staff number greater than the number of staves in the part
- set the number of staves in a part to the maximum of the value specified in the part / measure / attributes / staves node and the maximum value present in the part (in the part / measure / note / staff node.

The more elegant fix would be the second one.

Am investigating.