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

Commit 5ec161bb authored by Ivan Lozano's avatar Ivan Lozano
Browse files

Fix audioflinger in overflow sanitized builds.

The loop as constructed in Track::triggerEvents potentially leads to
two unsigned integer overflows on the i = 0 loop.

This refactors the loop to prevent the overflow.

Bug: 30969751
Test: Compiles and device boots.
Change-Id: I7ac3223ab3197f5c475a4d09c99e6f05d0ddb208
parent eda72c27
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1102,11 +1102,12 @@ bool AudioFlinger::PlaybackThread::Track::presentationComplete(

void AudioFlinger::PlaybackThread::Track::triggerEvents(AudioSystem::sync_event_t type)
{
    for (size_t i = 0; i < mSyncEvents.size(); i++) {
    for (size_t i = 0; i < mSyncEvents.size();) {
        if (mSyncEvents[i]->type() == type) {
            mSyncEvents[i]->trigger();
            mSyncEvents.removeAt(i);
            i--;
        } else {
            ++i;
        }
    }
}