diff --git a/src/cubeb_jack.cpp b/src/cubeb_jack.cpp index b417078f..9d64b52c 100644 --- a/src/cubeb_jack.cpp +++ b/src/cubeb_jack.cpp @@ -405,12 +405,15 @@ cbjack_process(jack_nframes_t nframes, void * arg) for (int j = 0; j < MAX_STREAMS; j++) { cubeb_stream * stm = &ctx->streams[j]; - float * bufs_out[stm->out_params.channels]; - float * bufs_in[stm->in_params.channels]; if (!stm->in_use) continue; + float * bufs_out[MAX_CHANNELS] = {}; + float * bufs_in[MAX_CHANNELS] = {}; + XASSERT(stm->out_params.channels <= MAX_CHANNELS); + XASSERT(stm->in_params.channels <= MAX_CHANNELS); + // handle xruns by skipping audio that should have been played stm->position += t_jack_xruns * ctx->fragment_size * stm->ratio; @@ -851,6 +854,14 @@ cbjack_stream_init(cubeb * context, cubeb_stream ** stream, return CUBEB_ERROR_INVALID_FORMAT; } + if ((output_stream_params && + (output_stream_params->channels < 1 || + output_stream_params->channels > MAX_CHANNELS)) || + (input_stream_params && (input_stream_params->channels < 1 || + input_stream_params->channels > MAX_CHANNELS))) { + return CUBEB_ERROR_INVALID_FORMAT; + } + if ((input_device && input_device != JACK_DEFAULT_IN) || (output_device && output_device != JACK_DEFAULT_OUT)) { return CUBEB_ERROR_NOT_SUPPORTED;