MxSoundManager: use buffer size and don't rely on buffer capacity

This fixes a detect_container_overflow address sanitizer error.
This commit is contained in:
Anonymous Maarten 2026-01-01 00:58:27 +01:00
parent 6f192a3b1c
commit f78d3ffad8

View File

@ -148,7 +148,10 @@ void MxSoundManager::AudioStreamCallback(
)
{
static vector<MxU8> g_buffer;
g_buffer.reserve(p_additionalAmount);
if (p_additionalAmount > g_buffer.size()) {
// We resize and don't reserve memory to avoid an AddressSanitizerContainerOverflow asan error
g_buffer.resize(p_additionalAmount);
}
MxSoundManager* manager = (MxSoundManager*) p_userdata;
ma_uint32 bytesPerFrame = ma_get_bytes_per_frame(ma_format_f32, ma_engine_get_channels(manager->m_engine));