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

Commit 7f0f4312 authored by Eric Laurent's avatar Eric Laurent
Browse files

audi policy manager: fix use after free in initialize()

Fix regression introduced by commit 11d30104 in cleanup loop in
AudioPolicyManager::initialize().

Bug: 123080575
Test: make
Change-Id: I048eeb5f5c6e6bc83dd2b31af4dd600bc07ab1a2
parent 88a1999c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4070,7 +4070,8 @@ status_t AudioPolicyManager::initialize() {
    }
    // make sure all attached devices have been allocated a unique ID
    auto checkAndSetAvailable = [this](auto& devices) {
        for (const auto &device : devices) {
        for (size_t i = 0; i < devices.size();) {
            const auto &device = devices[i];
            if (!device->isAttached()) {
                ALOGW("device %s is unreachable", device->toString().c_str());
                devices.remove(device);
@@ -4078,6 +4079,7 @@ status_t AudioPolicyManager::initialize() {
            }
            // Device is now validated and can be appended to the available devices of the engine
            mEngine->setDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_AVAILABLE);
            i++;
        }
    };
    checkAndSetAvailable(mAvailableOutputDevices);