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

Commit 6235afe2 authored by Andy Hung's avatar Andy Hung Committed by android-build-merger
Browse files

Track: Check buffer size of static tracks am: cf39f0e6

am: 6790e790

Change-Id: I2cb0ce9e086e15b037f6de6086072d107fbaf571
parents 24ef54ec 6790e790
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -367,6 +367,21 @@ AudioFlinger::PlaybackThread::Track::Track(
            mAudioTrackServerProxy = new AudioTrackServerProxy(mCblk, mBuffer, frameCount,
                    mFrameSize);
        } else {
            // Is the shared buffer of sufficient size?
            // (frameCount * mFrameSize) is <= SIZE_MAX, checked in TrackBase.
            if (sharedBuffer->size() < frameCount * mFrameSize) {
                // Workaround: clear out mCblk to indicate track hasn't been properly created.
                mCblk->~audio_track_cblk_t();   // destroy our shared-structure.
                if (mClient == 0) {
                    free(mCblk);
                }
                mCblk = NULL;

                mSharedBuffer.clear(); // release shared buffer early
                android_errorWriteLog(0x534e4554, "38340117");
                return;
            }

            mAudioTrackServerProxy = new StaticAudioTrackServerProxy(mCblk, mBuffer, frameCount,
                    mFrameSize);
        }