Bug 1267637: [opus] P3. Reject audio data with unsupported audio configuration. r?gerald
MozReview-Commit-ID: 5od4WqRAorK
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp
+++ b/dom/media/platforms/agnostic/OpusDecoder.cpp
@@ -98,20 +98,20 @@ OpusDataDecoder::DecodeHeader(const unsi
MOZ_ASSERT(!mDecodedHeader);
mDecodedHeader = true;
mOpusParser = new OpusParser;
if (!mOpusParser->DecodeHeader(const_cast<unsigned char*>(aData), aLength)) {
return NS_ERROR_FAILURE;
}
int channels = mOpusParser->mChannels;
- // No channel mapping for more than 8 channels.
- if (channels > 8) {
- OPUS_DEBUG("No channel mapping for more than 8 channels. Source is %d channels",
- channels);
+
+ AudioConfig::ChannelLayout layout(channels);
+ if (!layout.IsValid()) {
+ OPUS_DEBUG("Invalid channel mapping. Source is %d channels", channels);
return NS_ERROR_FAILURE;
}
AudioConfig::ChannelLayout vorbisLayout(
channels, VorbisDataDecoder::VorbisLayout(channels));
AudioConfig::ChannelLayout smpteLayout(channels);
static_assert(sizeof(mOpusParser->mMappingTable) / sizeof(mOpusParser->mMappingTable[0]) >= MAX_AUDIO_CHANNELS,
"Invalid size set");