From 0ac09d1f67930b203bab35803a24b87e0aaea5d3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 7 Jan 2020 14:10:14 -0700 Subject: fix serious but rare error in RTMidiBuffer's storage of MIDI events with size > 3 sizeof (T) is in units of bytes, not bits. Use C++ standard CHAR_BITS instead. --- libs/ardour/rt_midibuffer.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libs/ardour/rt_midibuffer.cc') diff --git a/libs/ardour/rt_midibuffer.cc b/libs/ardour/rt_midibuffer.cc index e2490c23c2..6227b77b2d 100644 --- a/libs/ardour/rt_midibuffer.cc +++ b/libs/ardour/rt_midibuffer.cc @@ -165,7 +165,7 @@ RTMidiBuffer::dump (uint32_t cnt) /* more than 3 bytes ... indirect */ - uint32_t offset = item->offset & ~(1<<(sizeof(uint8_t)-1)); + uint32_t offset = item->offset & ~(1<<(CHAR_BIT-1)); Blob* blob = reinterpret_cast (&_pool[offset]); size = blob->size; @@ -205,7 +205,7 @@ RTMidiBuffer::write (TimeType time, Evoral::EventType /*type*/, uint32_t size, c uint32_t off = store_blob (size, buf); /* non-zero MSbit indicates that the data (more than 3 bytes) is not inline */ - _data[_size].offset = (off | (1<<(sizeof(uint8_t)-1))); + _data[_size].offset = (off | (1<<(CHAR_BIT-1))); } else { @@ -312,7 +312,7 @@ RTMidiBuffer::read (MidiBuffer& dst, samplepos_t start, samplepos_t end, MidiSta /* more than 3 bytes ... indirect */ - uint32_t offset = item->offset & ~(1<<(sizeof(uint8_t)-1)); + uint32_t offset = item->offset & ~(1<<(CHAR_BIT-1)); Blob* blob = reinterpret_cast (&_pool[offset]); size = blob->size; -- cgit v1.2.3