diff options
author | Felicia Lim <flim@google.com> | 2021-09-28 07:52:22 +0300 |
---|---|---|
committer | Felicia Lim <flim@google.com> | 2021-09-28 07:52:22 +0300 |
commit | a8e6a77c5fe0c37aa6788f939f24f8cd22ae2652 (patch) | |
tree | 9e6c3a58c63f17e88c0b3f81b3d493755c27ff02 /src | |
parent | 6b6035ae4a29abbd237463d84a45fbeb0d92bc18 (diff) |
Check channels/stream counts and mapping when creating the multistream
encoder
Diffstat (limited to 'src')
-rw-r--r-- | src/opus_multistream_encoder.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/opus_multistream_encoder.c b/src/opus_multistream_encoder.c index 93204a14..213e3eb2 100644 --- a/src/opus_multistream_encoder.c +++ b/src/opus_multistream_encoder.c @@ -443,7 +443,8 @@ static int opus_multistream_encoder_init_impl( char *ptr; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams) || + (streams+coupled_streams>channels)) return OPUS_BAD_ARG; st->arch = opus_select_arch(); @@ -459,8 +460,7 @@ static int opus_multistream_encoder_init_impl( st->layout.mapping[i] = mapping[i]; if (!validate_layout(&st->layout)) return OPUS_BAD_ARG; - if (mapping_type == MAPPING_TYPE_SURROUND && - !validate_encoder_layout(&st->layout)) + if (!validate_encoder_layout(&st->layout)) return OPUS_BAD_ARG; if (mapping_type == MAPPING_TYPE_AMBISONICS && !validate_ambisonics(st->layout.nb_channels, NULL, NULL)) @@ -595,7 +595,8 @@ OpusMSEncoder *opus_multistream_encoder_create( int ret; OpusMSEncoder *st; if ((channels>255) || (channels<1) || (coupled_streams>streams) || - (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams)) + (streams<1) || (coupled_streams<0) || (streams>255-coupled_streams) || + (streams+coupled_streams>channels)) { if (error) *error = OPUS_BAD_ARG; |