[libadapter] Fix nullpointer in acceptchanges
Check the layer still exists upon accepting changes.
Bug: 36205238
Test: AUPT
Change-Id: I8443265ecc7b8b0a12347439fd75b138d14c7e3a
diff --git a/libs/hwc2on1adapter/HWC2On1Adapter.cpp b/libs/hwc2on1adapter/HWC2On1Adapter.cpp
index 03297ca..e35bfc9 100644
--- a/libs/hwc2on1adapter/HWC2On1Adapter.cpp
+++ b/libs/hwc2on1adapter/HWC2On1Adapter.cpp
@@ -538,6 +538,12 @@
for (auto& change : mChanges->getTypeChanges()) {
auto layerId = change.first;
auto type = change.second;
+ if (mDevice.mLayers.count(layerId) == 0) {
+ // This should never happen but somehow does.
+ ALOGW("Cannot accept change for unknown layer (%" PRIu64 ")",
+ layerId);
+ continue;
+ }
auto layer = mDevice.mLayers[layerId];
layer->setCompositionType(type);
}