diff options
author | David Robillard <d@drobilla.net> | 2014-12-30 23:07:19 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-12-30 23:10:11 -0500 |
commit | 168d1879943859653e197237e9baf57f3feb909e (patch) | |
tree | 220e4537d9e7090c8bab9fac1f1f58cab756951b /libs/evoral/src/SMF.cpp | |
parent | 4facff3b8ea68cf8f90e63e9f41b27349b1a43d6 (diff) |
Load what we can from broken/truncated MIDI files.
We're still a very long way from tolerant of weird SMF files (libsmf takes a
"crash if input is not exactly perfect" philosophy, if we're going to be polite
and elevate such a thing to "philosophy"), but at least we'll get what's there
from files truncated by old broken versions of Ardour or other situations.
Diffstat (limited to 'libs/evoral/src/SMF.cpp')
-rw-r--r-- | libs/evoral/src/SMF.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp index a989d01353..218e2851ff 100644 --- a/libs/evoral/src/SMF.cpp +++ b/libs/evoral/src/SMF.cpp @@ -286,7 +286,11 @@ SMF::read_event(uint32_t* delta_t, uint32_t* size, uint8_t** buf, event_id_t* no memcpy(*buf, event->midi_buffer, size_t(event_size)); *size = event_size; - assert(midi_event_is_valid(*buf, *size)); + if (!midi_event_is_valid(*buf, *size)) { + cerr << "WARNING: SMF ignoring illegal MIDI event" << endl; + *size = 0; + return -1; + } /* printf("SMF::read_event @ %u: ", *delta_t); for (size_t i = 0; i < *size; ++i) { |