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

Commit 6918a851 authored by Ray Essick's avatar Ray Essick Committed by android-build-merger
Browse files

Merge "avoid 32-bit integer overflow" into oc-dev am: 88b32e4b am: f6b45069

am: b3399c1c

Change-Id: Iaf12457999b88f81b21a8964f87660adf91437b1
parents 7bfd89a7 b3399c1c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -5298,8 +5298,9 @@ void ACodec::sendFormatChange() {
        CHECK(mOutputFormat->findInt32("channel-count", &channelCount));
        CHECK(mOutputFormat->findInt32("sample-rate", &sampleRate));
        if (mSampleRate != 0 && sampleRate != 0) {
            mEncoderDelay = mEncoderDelay * sampleRate / mSampleRate;
            mEncoderPadding = mEncoderPadding * sampleRate / mSampleRate;
            // avoiding 32-bit overflows in intermediate values
            mEncoderDelay = (int32_t)((((int64_t)mEncoderDelay) * sampleRate) / mSampleRate);
            mEncoderPadding = (int32_t)((((int64_t)mEncoderPadding) * sampleRate) / mSampleRate);
            mSampleRate = sampleRate;
        }
        if (mSkipCutBuffer != NULL) {