Add a null check in case device disappears.
This is a race condition possible when the caller get display IBinder
the display is still here, but when it tries to take screenshot with
that display, the display disappeared before it.
Bug: 75324434
Test: smoke tests on walleye. This is a race so hard to verify.
Change-Id: I5a107862e0b442840038b0956736e9661f556a23
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index cb410a1..588cb2a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4409,6 +4409,8 @@
if (CC_UNLIKELY(display == 0)) return BAD_VALUE;
const sp<const DisplayDevice> device(getDisplayDeviceLocked(display));
+ if (CC_UNLIKELY(device == 0)) return BAD_VALUE;
+
DisplayRenderArea renderArea(device, sourceCrop, reqHeight, reqWidth, rotation);
auto traverseLayers = std::bind(std::mem_fn(&SurfaceFlinger::traverseLayersInDisplay), this,