diff options
| author | 2022-11-23 18:50:09 +0000 | |
|---|---|---|
| committer | 2022-11-23 18:50:09 +0000 | |
| commit | aa548fdb280f58ca249f5c5d96b3911cda966abb (patch) | |
| tree | 6856ff39f27462d2c99029067abb16fe6b15399f | |
| parent | 52363196454b0bfca4c395bb711d806c9b33ea44 (diff) | |
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
| -rw-r--r-- | services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp index 1108246e47..7afa1444df 100644 --- a/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp +++ b/services/surfaceflinger/FrontEnd/LayerLifecycleManager.cpp @@ -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())); - mLayers.erase(mLayers.end() - 1); + if (it == mLayers.end() - 1) { + it = mLayers.erase(mLayers.end() - 1); + } else { + mLayers.erase(mLayers.end() - 1); + } } else { it++; } |