SDL: GPU: Validate that buffer size is at least 4 bytes (b3f4b)

From b3f4ba07259aaa3d5689f47311f8ba1de24d8645 Mon Sep 17 00:00:00 2001
From: cosmonaut <[EMAIL REDACTED]>
Date: Mon, 13 Oct 2025 11:02:52 -0700
Subject: [PATCH] GPU: Validate that buffer size is at least 4 bytes

(cherry picked from commit b067dfa345e00d1a406ea29338f9140390c539f4)
---
 src/gpu/SDL_gpu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c
index bfdd94ba5e0eb..4c047713560d6 100644
--- a/src/gpu/SDL_gpu.c
+++ b/src/gpu/SDL_gpu.c
@@ -62,7 +62,7 @@
     }
 
 #if 0
-// The below validation is too aggressive, since there are advanced situations 
+// The below validation is too aggressive, since there are advanced situations
 // where this is legal. This is being temporarily disabled for further review.
 // See: https://github.com/libsdl-org/SDL/issues/13871
 #define CHECK_SAMPLER_TEXTURES                                                                                                          \
@@ -1320,6 +1320,12 @@ SDL_GPUBuffer *SDL_CreateGPUBuffer(
         return NULL;
     }
 
+    if (device->debug_mode) {
+        if (createinfo->size < 4) {
+            SDL_assert_release(!"Cannot create a buffer with size less than 4 bytes!");
+        }
+    }
+
     const char *debugName = SDL_GetStringProperty(createinfo->props, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, NULL);
 
     return device->CreateBuffer(