From 1c7967fc8821514693ad2d8eef02748221d8416e Mon Sep 17 00:00:00 2001 From: David Reid Date: Fri, 4 Jul 2025 06:37:08 +1000 Subject: [PATCH] PulseAudio: Fix a crash if the requested channel count is too high. --- miniaudio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/miniaudio.h b/miniaudio.h index cefa6af8..3f3a3bd1 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -31890,6 +31890,11 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi ss.channels = pDescriptorCapture->channels; } + /* PulseAudio has a maximum channel count of 32. We'll get a crash if this is exceeded. */ + if (ss.channels > 32) { + ss.channels = 32; + } + /* Use a default channel map. */ ((ma_pa_channel_map_init_extend_proc)pDevice->pContext->pulse.pa_channel_map_init_extend)(&cmap, ss.channels, pConfig->pulse.channelMap); @@ -32042,6 +32047,11 @@ static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_confi ss.channels = pDescriptorPlayback->channels; } + /* PulseAudio has a maximum channel count of 32. We'll get a crash if this is exceeded. */ + if (ss.channels > 32) { + ss.channels = 32; + } + /* Use a default channel map. */ ((ma_pa_channel_map_init_extend_proc)pDevice->pContext->pulse.pa_channel_map_init_extend)(&cmap, ss.channels, pConfig->pulse.channelMap);