This commit is contained in:
CiroZDP 2025-12-29 21:32:28 +00:00 committed by GitHub
commit 54e20d509d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -248,9 +248,8 @@ int _glfw_max(int a, int b)
void* _glfw_calloc(size_t count, size_t size) void* _glfw_calloc(size_t count, size_t size)
{ {
if (count && size) if (!count || !size)
{ return NULL;
void* block;
if (count > SIZE_MAX / size) if (count > SIZE_MAX / size)
{ {
@ -258,17 +257,15 @@ void* _glfw_calloc(size_t count, size_t size)
return NULL; return NULL;
} }
block = _glfw.allocator.allocate(count * size, _glfw.allocator.user); const size_t total_size = count * size;
if (block) void* block = _glfw.allocator.allocate(total_size, _glfw.allocator.user);
return memset(block, 0, count * size); if (!block)
else
{ {
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL); _glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
return NULL; return NULL;
} }
}
else return memset(block, 0, total_size);
return NULL;
} }
void* _glfw_realloc(void* block, size_t size) void* _glfw_realloc(void* block, size_t size)