vkd3d-shader: Avoid div by zero on assert in vkd3d_calloc() (ubsan).

This commit is contained in:
Francisco Casas 2024-06-06 12:57:38 -04:00 committed by Henri Verbeet
parent 94c74d2c00
commit becdcec147
Notes: Henri Verbeet 2024-08-20 21:34:57 +02:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1006

View File

@ -43,7 +43,7 @@ static inline void *vkd3d_realloc(void *ptr, size_t size)
static inline void *vkd3d_calloc(size_t count, size_t size) static inline void *vkd3d_calloc(size_t count, size_t size)
{ {
void *ptr; void *ptr;
VKD3D_ASSERT(count <= ~(size_t)0 / size); VKD3D_ASSERT(!size || count <= ~(size_t)0 / size);
if (!(ptr = calloc(count, size))) if (!(ptr = calloc(count, size)))
ERR("Out of memory.\n"); ERR("Out of memory.\n");
return ptr; return ptr;