mirror of
https://github.com/libretro/RetroArch
synced 2025-04-03 10:21:31 +00:00
Merge pull request #916 from mprobinson/jack-fix
Fix buffer overflow in JACK audio driver
This commit is contained in:
commit
bd3adc5aaa
14
audio/jack.c
14
audio/jack.c
@ -214,14 +214,18 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
size_t j;
|
size_t j;
|
||||||
jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING];
|
jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO];
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
|
||||||
for (j = 0; j < FRAMES(size); j++)
|
|
||||||
out_deinterleaved_buffer[i][j] = buf[j * 2 + i];
|
|
||||||
|
|
||||||
size_t frames = FRAMES(size);
|
size_t frames = FRAMES(size);
|
||||||
|
|
||||||
|
// Avoid buffer overflow if a DSP plugin generated a huge number of frames
|
||||||
|
if (frames > AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO)
|
||||||
|
frames = AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO;
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
for (j = 0; j < frames; j++)
|
||||||
|
out_deinterleaved_buffer[i][j] = buf[j * 2 + i];
|
||||||
|
|
||||||
size_t written = 0;
|
size_t written = 0;
|
||||||
while (written < frames)
|
while (written < frames)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user