Bug 1414632 - Prevent division by zero in webrtc::Merge::SignalScaling; r=jesup

A zero input_length here would be caused by a decoder error in
NetEqImpl::Decode(). Looking at the code in GetAudioInternal() which calls
Decode() it appears that the intention is to continue processing even if no new
audio data is decoded. Based on this, it seems safest to just skip muting in
SignalScaling if the input_length is zero.

The other potential cause of a division by zero here is if fs_mult_ is zero which
should not normally happen. But there's no harm in checking for that as well.


MozReview-Commit-ID: J0pd2wbjeZl

--HG--
extra : rebase_source : 5206abd1f85986d395a7eead148cb06d1d050842
This commit is contained in:
Dan Minor 2017-11-08 12:39:53 -05:00
Родитель 6e900ce0c3
Коммит 93e787c563
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -211,6 +211,12 @@ int16_t Merge::SignalScaling(const int16_t* input, size_t input_length,
// Adjust muting factor if new vector is more or less of the BGN energy.
const size_t mod_input_length =
std::min(static_cast<size_t>(64 * fs_mult_), input_length);
// Missing input, do no muting
if (mod_input_length == 0) {
return 16384;
}
const int16_t expanded_max =
WebRtcSpl_MaxAbsValueW16(expanded_signal, mod_input_length);
int32_t factor = (expanded_max * expanded_max) /