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

Commit 3b1b8aff authored by Garfield Tan's avatar Garfield Tan
Browse files

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
parent 6e01adc9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4409,6 +4409,8 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
    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,