Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1610dca9 authored by Niel Alejandro Paz's avatar Niel Alejandro Paz Committed by Steve Kondik
Browse files

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: I35051ab1ee84e5b51e9c719781387e96b28ab656
Signed-off-by: default avatarNiel Alejandro Paz <niel.paz.hernandez@intel.com>
Signed-off-by: default avatarDan Liang <dan.liang@intel.com>
parent ce0ebe4d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -200,15 +200,17 @@ status_t WAVExtractor::init() {
            }

            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 != 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]);