From c5a689c6d6ac9d792236ae5392654e7cf3c42dc1 Mon Sep 17 00:00:00 2001
From: cosmonaut <evan@moonside.games>
Date: Mon, 17 Jan 2022 21:28:25 -0800
Subject: [PATCH] fix bad realloc

---
 src/Refresh_Driver_Vulkan.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c
index a473bbc..bdc2200 100644
--- a/src/Refresh_Driver_Vulkan.c
+++ b/src/Refresh_Driver_Vulkan.c
@@ -6300,7 +6300,9 @@ static void VULKAN_INTERNAL_MaybeExpandTransferBuffer(
 			nextStagingSize *= 2;
 		}
 
-		commandBuffer->transferBuffers = SDL_realloc(commandBuffer->transferBuffers, sizeof(VulkanTransferBuffer*) * commandBuffer->transferBufferCount);
+		commandBuffer->transferBuffers = SDL_realloc(commandBuffer->transferBuffers, sizeof(VulkanTransferBuffer*) * (commandBuffer->transferBufferCount + 1));
+		commandBuffer->transferBuffers[commandBuffer->transferBufferCount] = SDL_malloc(sizeof(VulkanTransferBuffer));
+
 		commandBuffer->transferBuffers[commandBuffer->transferBufferCount]->offset = 0;
 
 		commandBuffer->transferBuffers[commandBuffer->transferBufferCount]->buffer = VULKAN_INTERNAL_CreateBuffer(
@@ -7544,7 +7546,7 @@ static void VULKAN_QueueDestroyBuffer(
 		renderer->buffersToDestroyCount
 	] = vulkanBuffer;
 	renderer->buffersToDestroyCount += 1;
-	
+
 	SDL_free(vulkanBuffer);
 
 	SDL_UnlockMutex(renderer->disposeLock);
@@ -8579,7 +8581,7 @@ static void VULKAN_Submit(
 	if (present)
 	{
 		/* Wait for the previous submission to complete */
-		if (renderer->usedFenceCount)
+		if (renderer->usedFenceCount > 0)
 		{
 			vulkanResult = renderer->vkWaitForFences(
 				renderer->logicalDevice,