GPU: Validate that buffer size is at least 4 bytes

This commit is contained in:
cosmonaut
2025-10-13 11:02:52 -07:00
parent 361f7e0873
commit b067dfa345

View File

@@ -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 \
@@ -1340,6 +1340,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(