diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index a415323261..165ae371da 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1742,8 +1742,13 @@ LV2Plugin::write_to(RingBuffer* dest, const uint8_t* body) { const uint32_t buf_size = sizeof(UIMessage) + size; - vector buf(buf_size); + if (dest->write_space () < buf_size) { + /* Do not write partial message */ + return false; + } + + vector buf(buf_size); UIMessage* msg = (UIMessage*)&buf[0]; msg->index = index; msg->protocol = protocol; @@ -1781,6 +1786,11 @@ LV2Plugin::write_from_ui(uint32_t index, _from_ui = new RingBuffer(rbs); } + if (_from_ui->write_space () < size) { + error << string_compose (_("LV2<%1>: Error writing from UI to plugin"), name()) << endmsg; + return false; + } + if (!write_to(_from_ui, index, protocol, size, body)) { error << string_compose (_("LV2<%1>: Error writing from UI to plugin"), name()) << endmsg; return false;