segfault if chord() returns null pointer in note.cpp

• Dec 12, 2010 - 17:52

when notes are put on a place where a rest is, there can be a crash, because of unchecked null pointer in note.cpp.

in void Note::setTrack(int val) it should be

if (chord()) {
for (int i = 0; i < chord()->dots(); ++i) {
if (_dots[i])
_dots[i]->setTrack(val);
}
}

and I haven't experienced crashes from this one, but it looks similar in
void Note::scanElements(void* data, void (*func)(void*, Element*))

if (chord()) {
for (int i = 0; i < chord()->dots(); ++i) {
if (_dots[i])
func(data, _dots[i]);
}
}

This is only a quick fix, to prevent crashes, I don't know, if this provides correct behaviour in further program execution. However, the result looks right on the sheet.

Greetings,
Friedemann

Do you still have an unanswered question? Please log in first to post your question.