diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 7f6ed7d837..5dc128f3a9 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -1565,10 +1565,12 @@ MidiView::begin_write() XXX this should not happen. */ - for (unsigned i = 0; i < 128; ++i) { - delete _active_notes[i]; + if (_active_notes) { + for (unsigned i = 0; i < 128; ++i) { + delete _active_notes[i]; + } + delete [] _active_notes; } - delete [] _active_notes; /* reallocate */ @@ -1585,12 +1587,13 @@ MidiView::begin_write() void MidiView::end_write() { - for (unsigned i = 0; i < 128; ++i) { - delete _active_notes[i]; + if (_active_notes) { + for (unsigned i = 0; i < 128; ++i) { + delete _active_notes[i]; + } + delete [] _active_notes; } - delete [] _active_notes; - _active_notes = nullptr; _marked_for_selection.clear(); _marked_for_velocity.clear();