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

Commit aa548fdb authored by Vishnu Nair's avatar Vishnu Nair
Browse files

SF: Avoid accessing an invalidated iterator

If we erase the element currently pointed to by
the iterator, the iterator will be invalidated.
Fix this by updating the iterator.

Bug: 238781169
Test: presubmit
Change-Id: I5306cb15f7665f53475ce2fa3b5ef6a897f73dca
parent 52363196
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -123,7 +123,11 @@ void LayerLifecycleManager::onHandlesDestroyed(const std::vector<uint32_t>& dest
            ALOGV("%s destroyed layer %s", __func__, layer->getDebugStringShort().c_str());
            std::iter_swap(it, mLayers.end() - 1);
            mDestroyedLayers.emplace_back(std::move(mLayers.back()));
            if (it == mLayers.end() - 1) {
                it = mLayers.erase(mLayers.end() - 1);
            } else {
                mLayers.erase(mLayers.end() - 1);
            }
        } else {
            it++;
        }