Procházet zdrojové kódy

GPU: Validate that buffer size is at least 4 bytes

(cherry picked from commit b067dfa345e00d1a406ea29338f9140390c539f4)
cosmonaut před 4 měsíci
rodič
revize
b3f4ba0725
1 změnil soubory, kde provedl 7 přidání a 1 odebrání
  1. 7 1
      src/gpu/SDL_gpu.c

+ 7 - 1
src/gpu/SDL_gpu.c

@@ -62,7 +62,7 @@
     }
     }
 
 
 #if 0
 #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.
 // where this is legal. This is being temporarily disabled for further review.
 // See: https://github.com/libsdl-org/SDL/issues/13871
 // See: https://github.com/libsdl-org/SDL/issues/13871
 #define CHECK_SAMPLER_TEXTURES                                                                                                          \
 #define CHECK_SAMPLER_TEXTURES                                                                                                          \
@@ -1320,6 +1320,12 @@ SDL_GPUBuffer *SDL_CreateGPUBuffer(
         return NULL;
         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);
     const char *debugName = SDL_GetStringProperty(createinfo->props, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, NULL);
 
 
     return device->CreateBuffer(
     return device->CreateBuffer(