[plasma/kwin/Plasma/6.7] src/vulkan: vulkan: drop the graphics buffer when texture import fails
Vlad Zahorodnii <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 4cff9f816c69a2b475651ce53d981a7ca428f361 by Vlad Zahorodnii. Committed on 10/08/2026 at 12:01. Pushed by vladz into branch 'Plasma/6.7'. vulkan: drop the graphics buffer when texture import fails When importBuffer() fails, the allocated GraphicsBuffer was never dropped, leaking the buffer and its underlying resources. Drop the buffer before returning in both VulkanSwapchain::acquire() and VulkanSwapchain::create(). (cherry picked from commit ca0c0d7f1fd52b6c6d5cdb092ce8a8c9a55c8ed7) Co-authored-by: zhang shoucheng <[email protected]> M +2 -0 src/vulkan/vulkan_swapchain.cpp https://invent.kde.org/plasma/kwin/-/commit/4cff9f816c69a2b475651ce53d981a7ca428f361 diff --git a/src/vulkan/vulkan_swapchain.cpp b/src/vulkan/vulkan_swapchain.cpp index 81352b12bd1..e5ac4d7b5ae 100644 --- a/src/vulkan/vulkan_swapchain.cpp +++ b/src/vulkan/vulkan_swapchain.cpp @@ -111,6 +111,7 @@ std::shared_ptr<VulkanSwapchainSlot> VulkanSwapchain::acquire() auto texture = m_device->importBuffer(buffer, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); if (!texture) { + buffer->drop(); return nullptr; } auto slot = std::make_shared<VulkanSwapchainSlot>(buffer, std::move(texture)); @@ -150,6 +151,7 @@ std::unique_ptr<VulkanSwapchain> VulkanSwapchain::create(VulkanDevice *device, G } auto texture = device->importBuffer(buffer, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT); if (!texture) { + buffer->drop(); return nullptr; } auto slot = std::make_shared<VulkanSwapchainSlot>(buffer, std::move(texture));