=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: winevulkan: Free all command buffers when vkAllocateCommandBuffers() fails.

Alexandre Julliard julliard at winehq.org
Thu Aug 30 16:34:42 CDT 2018


Module: wine
Branch: master
Commit: b62d4ea6ed49f9e9aaa7e6303741c0274df03ab3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b62d4ea6ed49f9e9aaa7e6303741c0274df03ab3

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Thu Aug 30 12:22:34 2018 +0200

winevulkan: Free all command buffers when vkAllocateCommandBuffers() fails.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winevulkan/vulkan.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c
index f500602..4e0d999 100644
--- a/dlls/winevulkan/vulkan.c
+++ b/dlls/winevulkan/vulkan.c
@@ -540,25 +540,24 @@ VkResult WINAPI wine_vkAllocateCommandBuffers(VkDevice device,
 
         buffers[i]->base.loader_magic = VULKAN_ICD_MAGIC_VALUE;
         buffers[i]->device = device;
+        list_add_tail(&pool->command_buffers, &buffers[i]->pool_link);
         res = device->funcs.p_vkAllocateCommandBuffers(device->device,
                 &allocate_info_host, &buffers[i]->command_buffer);
         if (res != VK_SUCCESS)
         {
             ERR("Failed to allocate command buffer, res=%d.\n", res);
+            buffers[i]->command_buffer = VK_NULL_HANDLE;
             break;
         }
-
-        list_add_tail(&pool->command_buffers, &buffers[i]->pool_link);
     }
 
     if (res != VK_SUCCESS)
     {
-        wine_vk_free_command_buffers(device, pool, i, buffers);
+        wine_vk_free_command_buffers(device, pool, i + 1, buffers);
         memset(buffers, 0, allocate_info->commandBufferCount * sizeof(*buffers));
-        return res;
     }
 
-    return VK_SUCCESS;
+    return res;
 }
 
 void WINAPI wine_vkCmdExecuteCommands(VkCommandBuffer buffer, uint32_t count,




More information about the wine-cvs mailing list