From 25251a94058231f063d3385e30ff903b596e8a14 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 11 Oct 2024 19:30:57 -0700
Subject: [PATCH] Fixed warning C4723: potential divide by 0
---
src/gpu/SDL_gpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c
index c550c7a5703d9..0450d92521189 100644
--- a/src/gpu/SDL_gpu.c
+++ b/src/gpu/SDL_gpu.c
@@ -2803,8 +2803,8 @@ Uint32 SDL_CalculateGPUTextureFormatSize(
Uint32 height,
Uint32 depth_or_layer_count)
{
- Uint32 blockWidth = Texture_GetBlockWidth(format);
- Uint32 blockHeight = Texture_GetBlockHeight(format);
+ Uint32 blockWidth = SDL_max(Texture_GetBlockWidth(format), 1);
+ Uint32 blockHeight = SDL_max(Texture_GetBlockHeight(format), 1);
Uint32 blocksPerRow = (width + blockWidth - 1) / blockWidth;
Uint32 blocksPerColumn = (height + blockHeight - 1) / blockHeight;
return depth_or_layer_count * blocksPerRow * blocksPerColumn * SDL_GPUTextureFormatTexelBlockSize(format);