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

Commit 0c6b7f42 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

graphics: fix leaks in IComposer default impl

When a layer is removed, remove its cached buffer/sidestream as well.

Test: fixed OOM
Change-Id: Ibafe18ff686ae6bcb1fc4baed30b7784d2b40529
parent 4c0d397f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -698,6 +698,14 @@ Return<void> HwcHal::createLayer(Display display, createLayer_cb hidl_cb)
Return<Error> HwcHal::destroyLayer(Display display, Layer layer)
{
    auto error = mDispatch.destroyLayer(mDevice, display, layer);
    if (error == HWC2_ERROR_NONE) {
        std::lock_guard<std::mutex> lock(mDisplayMutex);

        auto dpy = mDisplays.find(display);
        dpy->second.LayerBuffers.erase(layer);
        dpy->second.LayerSidebandStreams.erase(layer);
    }

    return static_cast<Error>(error);
}