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

Commit 09e60052 authored by Valerie Hau's avatar Valerie Hau
Browse files

Fix check for nullptr surface IBinder

Bug: 146345307
Test: build, boot, libsurfaceflinger_unittest, SurfaceFlinger_test
Change-Id: I79d5bb71beb573c3c8a150c938aa6d7fa301353f
parent d0d28e31
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -5482,7 +5482,10 @@ void SurfaceFlinger::SetInputWindowsListener::onSetInputWindowsFinished() {
}

sp<Layer> SurfaceFlinger::fromHandle(const sp<IBinder>& handle) {
    BBinder *b = handle->localBinder();
    BBinder* b = nullptr;
    if (handle) {
        b = handle->localBinder();
    }
    if (b == nullptr) {
        return nullptr;
    }
+5 −0
Original line number Diff line number Diff line
@@ -388,6 +388,11 @@ public:
    auto& mutableInternalHwcDisplayId() { return getHwComposer().mInternalHwcDisplayId; }
    auto& mutableExternalHwcDisplayId() { return getHwComposer().mExternalHwcDisplayId; }

    auto fromHandle(const sp<IBinder>& handle) {
        Mutex::Autolock _l(mFlinger->mStateLock);
        return mFlinger->fromHandle(handle);
    }

    ~TestableSurfaceFlinger() {
        // All these pointer and container clears help ensure that GMock does
        // not report a leaked object, since the SurfaceFlinger instance may
+5 −0
Original line number Diff line number Diff line
@@ -315,4 +315,9 @@ TEST_F(TransactionApplicationTest, BlockWithPriorTransaction_SyncInputWindows) {
    BlockedByPriorTransaction(/*flags*/ 0, /*syncInputWindows*/ true);
}

TEST_F(TransactionApplicationTest, FromHandle) {
    sp<IBinder> badHandle;
    auto ret = mFlinger.fromHandle(badHandle);
    EXPECT_EQ(nullptr, ret.get());
}
} // namespace android