mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
VSTMidiEventList: Silence clang-analyzer OOB read warning
This commit is contained in:
parent
641497918c
commit
0788df388b
1 changed files with 7 additions and 5 deletions
|
|
@ -53,12 +53,14 @@ class VSTMidiEventList
|
||||||
static auto& getEvent (Events& events, int index)
|
static auto& getEvent (Events& events, int index)
|
||||||
{
|
{
|
||||||
using EventType = decltype (&*events.events);
|
using EventType = decltype (&*events.events);
|
||||||
|
static constexpr auto offset = offsetof (Vst2::VstEvents, events);
|
||||||
|
|
||||||
// We static cast rather than using a direct array index here to circumvent
|
auto* bytes = reinterpret_cast<std::conditional_t<std::is_const_v<std::remove_pointer_t<EventType>>,
|
||||||
// UB sanitizer's bounds-checks. The original struct is supposed to contain
|
const std::byte*,
|
||||||
// a variable-length array, but the declaration uses a size of "2" for this
|
std::byte*>> (&events);
|
||||||
// member.
|
auto* array = reinterpret_cast<EventType> (bytes + offset);
|
||||||
return static_cast<EventType> (events.events)[index];
|
|
||||||
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Vst2::VstEvent* const& getEvent (int index) const { return getEvent (*events, index); }
|
Vst2::VstEvent* const& getEvent (int index) const { return getEvent (*events, index); }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue