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

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

vulkan: avoid double-free in InitSharedPtr

When std::shared_ptr fails to allocate its internal data, it deletes the
managed object automatically.  We should not call obj->common.decRef on
std::bad_alloc.

Bug: 28039233
Change-Id: I1fe00c16e83e426602eac96d8b86afb4fd4830e6
parent 79632ee4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ std::shared_ptr<T> InitSharedPtr(Host host, T* obj) {
            obj, NativeBaseDeleter<T>(),
            VulkanAllocator<T>(*GetAllocator(host), AllocScope<Host>::kScope));
    } catch (std::bad_alloc&) {
        obj->common.decRef(&obj->common);
        return nullptr;
    }
}