13
0

Check for MIDI buffer overflow when merging into an empty buffer

This can happen if the buffers have different sizes.
This fixes crashes that bisected to 7c37a18b7, but it is not the root
cause; it just happened to make things worse.
This commit is contained in:
Hector Martin 2020-11-10 20:41:54 +09:00
parent f2d04dfb1f
commit 0979097cae

View File

@ -442,15 +442,15 @@ MidiBuffer::merge_in_place (const MidiBuffer &other)
return true;
}
if (size() + other.size() > _capacity) {
return false;
}
if (size() == 0) {
copy (other);
return true;
}
if (size() + other.size() > _capacity) {
return false;
}
const_iterator them = other.begin();
iterator us = begin();