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

Commit 30a9b983 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

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

parents b1129e1d 7f0f4312
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);