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

Commit dc6f5b98 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Check for null layer handles from clients

Fixes: 145096599
Test: Checked passing in a null layer handle doesn't crash surfaceflinger
Change-Id: I1150d25febc4c304c47740e7355130f9b83dd8db
parent a3c5d232
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -3118,7 +3118,13 @@ uint32_t SurfaceFlinger::setClientStateLocked(
        listenerCallbacks.insert(listener);
    }

    sp<Layer> layer(fromHandle(s.surface));
    sp<Layer> layer = nullptr;
    if (s.surface) {
        layer = fromHandle(s.surface);
    } else {
        // The client may provide us a null handle. Treat it as if the layer was removed.
        ALOGW("Attempt to set client state with a null layer handle");
    }
    if (layer == nullptr) {
        for (auto& [listener, callbackIds] : s.listeners) {
            mTransactionCompletedThread.registerUnpresentedCallbackHandle(