13
0

Zero length Events are illegal

This would later trigger an assert() in MidiRingBuffer<T>::read
when reading the status-byte, and cause undefined behavior down
in optimized builds.

It is unsure if this can happen, but it may explain
https://marcan.st/paste/LHDXNQ9x.txt
This commit is contained in:
Robin Gareus 2020-11-12 16:51:48 +01:00
parent d3eab4e309
commit ee74a932c6
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -118,7 +118,8 @@ template<typename Time>
inline uint32_t
EventRingBuffer<Time>::write(Time time, Evoral::EventType type, uint32_t size, const uint8_t* buf)
{
if (!buf || write_space() < (sizeof(Time) + sizeof(Evoral::EventType) + sizeof(uint32_t) + size)) {
assert (size > 0);
if (!buf || size == 0 || write_space() < (sizeof(Time) + sizeof(Evoral::EventType) + sizeof(uint32_t) + size)) {
return 0;
} else {
PBD::RingBufferNPT<uint8_t>::write ((uint8_t*)&time, sizeof(Time));