From 7ea38278f4b75f1a0afce8acdb80213abf6917ee Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 28 Jul 2021 18:40:29 +1000 Subject: [PATCH] Fix a bug with the slot allocator when the cap is not a multiple of 32. --- miniaudio.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index 308f871d..b7aadf07 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -37900,6 +37900,9 @@ MA_API ma_result ma_slot_allocator_alloc(ma_slot_allocator* pAllocator, ma_uint6 /* The slot index is required for constructing the output value. */ slotIndex = (iGroup << 5) + bitOffset; /* iGroup << 5 = iGroup * 32 */ + if (slotIndex >= pAllocator->capacity) { + return MA_OUT_OF_MEMORY; + } /* Increment the reference count before constructing the output value. */ pAllocator->pSlots[slotIndex] += 1;