Procházet zdrojové kódy

Fix potential memory leak in VULKAN_AcquireCommandBuffer() on error

(cherry picked from commit 77f4a8e2b8066d3bc376eab1ce443e57bc04d4ee)
Petar Popovic před 3 dny
rodič
revize
8bf6e23164
1 změnil soubory, kde provedl 5 přidání a 4 odebrání
  1. 5 4
      src/gpu/vulkan/SDL_gpu_vulkan.c

+ 5 - 4
src/gpu/vulkan/SDL_gpu_vulkan.c

@@ -9499,15 +9499,16 @@ static SDL_GPUCommandBuffer *VULKAN_AcquireCommandBuffer(
     VulkanCommandBuffer *commandBuffer =
         VULKAN_INTERNAL_GetInactiveCommandBufferFromPool(renderer, threadID);
 
+    if (commandBuffer == NULL) {
+        SDL_UnlockMutex(renderer->acquireCommandBufferLock);
+        return NULL;
+    }
+
     DescriptorSetCache *descriptorSetCache =
         VULKAN_INTERNAL_AcquireDescriptorSetCache(renderer);
 
     SDL_UnlockMutex(renderer->acquireCommandBufferLock);
 
-    if (commandBuffer == NULL) {
-        return NULL;
-    }
-
     commandBuffer->descriptorSetCache = descriptorSetCache;
 
     // Reset state