SDL: Fixed potential memory leak if vkCreateInstance() fails

From 504d8c2fc00641e1c17863965d730539afc9b823 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 4 Mar 2024 07:46:24 -0800
Subject: [PATCH] Fixed potential memory leak if vkCreateInstance() fails

---
 src/render/vulkan/SDL_render_vulkan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/render/vulkan/SDL_render_vulkan.c b/src/render/vulkan/SDL_render_vulkan.c
index 1222cc8f43831..7c3b0fd7a54ca 100644
--- a/src/render/vulkan/SDL_render_vulkan.c
+++ b/src/render/vulkan/SDL_render_vulkan.c
@@ -1702,11 +1702,11 @@ static VkResult VULKAN_CreateDeviceResources(SDL_Renderer *renderer, SDL_Propert
             instanceCreateInfo.enabledLayerCount = 1;
         }
         result = vkCreateInstance(&instanceCreateInfo, NULL, &rendererData->instance);
+        SDL_free((void *)instanceExtensionsCopy);
         if (result != VK_SUCCESS) {
             SDL_LogError(SDL_LOG_CATEGORY_RENDER, "vkCreateInstance(): %s\n", SDL_Vulkan_GetResultString(result));
             return result;
         }
-        SDL_free((void *)instanceExtensionsCopy);
     }
 
     /* Load instance Vulkan functions */