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

Commit 93eb5ecf authored by Marco Nelissen's avatar Marco Nelissen Committed by Gerrit Code Review
Browse files

Merge "Prevent divide by zero in WAVExtractor"

parents b70b09c9 e52267ad
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -311,9 +311,17 @@ status_t WAVExtractor::init() {
                        1000000LL * (mDataSize / 65 * 320) / 8000;
                } else {
                    size_t bytesPerSample = mBitsPerSample >> 3;

                    if (!bytesPerSample || !mNumChannels)
                        return ERROR_MALFORMED;

                    size_t num_samples = mDataSize / (mNumChannels * bytesPerSample);

                    if (!mSampleRate)
                        return ERROR_MALFORMED;

                    durationUs =
                        1000000LL * (mDataSize / (mNumChannels * bytesPerSample))
                            / mSampleRate;
                        1000000LL * num_samples / mSampleRate;
                }

                mTrackMeta->setInt64(kKeyDuration, durationUs);