Validation of Number of Channels on WAV files.
Corrects the validation of the number of channels that was causing a floating
point exception when this number is zero.
It also corrects the range of admitted channels on WAV files.
Change-Id: I21f005d1f30c1fd93206c6bce0d3be4b8307059c
Signed-off-by: Niel Alejandro Paz <niel.paz.hernandez@intel.com>
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Zhiquan Liu <zhiquan.liu@intel.com>
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index 51d639d..811929b 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -193,17 +193,17 @@
}
mNumChannels = U16_LE_AT(&formatSpec[2]);
+
+ if (mNumChannels < 1 || mNumChannels > 8) {
+ ALOGE("Unsupported number of channels (%d)", mNumChannels);
+ return ERROR_UNSUPPORTED;
+ }
+
if (mWaveFormat != WAVE_FORMAT_EXTENSIBLE) {
- if (mNumChannels == 0) {
- return ERROR_UNSUPPORTED;
- } else if (mNumChannels != 1 && mNumChannels != 2) {
+ if (mNumChannels != 1 && mNumChannels != 2) {
ALOGW("More than 2 channels (%d) in non-WAVE_EXT, unknown channel mask",
mNumChannels);
}
- } else {
- if (mNumChannels < 1 || mNumChannels > 8) {
- return ERROR_UNSUPPORTED;
- }
}
mSampleRate = U32_LE_AT(&formatSpec[4]);