Opened 7 months ago

Last modified 7 months ago

#1178 new Bug Report

MDA piano crashes with un-ordered MIDI events

Reported by: Robin Gareus Owned by: David Robillard
Priority: major Component: MDA
Keywords: Cc:


When the LV2 Atom Sequence contains events that are not ordered by time, the "frames to produce" calculation is not correct and the plugin will produce more output than required.

This effectively corrupts memory because *out0++ = ..; is called more than sampleFrames times.


diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index 75df330..f7abbce 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -335,6 +335,10 @@ void mdaPiano::processReplacing(float **inputs, float **outputs, int32_t sampleF
     bool end = lv2_atom_sequence_is_end(&eventInput->body, eventInput->atom.size, ev);
     frames = end ? sampleFrames : ev->time.frames;
+    if (frames < frame) {
+      ev = lv2_atom_sequence_next(ev);
+      continue;
+    }
     frames -= frame;
     frame += frames;

Parent issue with an example session to reproduce:

PS. Other MDA plugins may also be affected.

Change History (2)

comment:1 Changed 7 months ago by Robin Gareus

comment:2 Changed 7 months ago by David Robillard

Though the plugin shouldn't be crashing like this regardless, the host is not allowed to send buffers like this...

Note: See TracTickets for help on using tickets.