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.
Comments
In the case at hand, would it help to test for
cr
to be non null at the beginning ofMusicXMLParserPass2::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.
Pull request https://github.com/musescore/MuseScore/pull/3536 implements both solutions.
In reply to Pull request https://github… by Leon Vinken
Typo, PR implements the check for cr == null plus the second, more subtle, solution.
Fixed in branch master, commit ba3d8adf9a
fix #269948 - [MusicXML import] crash when importing single staff part referring to staff 2
Fixed in branch 2.2, commit e4ae5b4c73
fix #269948 - [MusicXML import] crash when importing single staff part referring to staff 2
Automatically closed -- issue fixed for 2 weeks with no activity.