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

Commit cf39f0e6 authored by Andy Hung's avatar Andy Hung
Browse files

Track: Check buffer size of static tracks

Merged-In: Ia7edd9a802905214a27961dbcec6352f6ef98f73
Merged-In: I633caf563d3607dbe4b9be10be1687efce33469c
Test: Native POC
Bug: 38340117
Change-Id: I633caf563d3607dbe4b9be10be1687efce33469c
parent 1159ffd5
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);
        }