mirror of
https://github.com/glfw/glfw
synced 2026-09-26 16:18:21 +03:00
Fix allocation size overflow check
This commit is contained in:
parent
c8d05935d4
commit
0c70f22410
1 changed files with 2 additions and 2 deletions
|
|
@ -251,13 +251,13 @@ void* _glfw_calloc(size_t count, size_t size)
|
|||
if (!count || !size)
|
||||
return NULL;
|
||||
|
||||
const size_t total_size = count * size;
|
||||
if (total_size > SIZE_MAX)
|
||||
if (count > SIZE_MAX / size)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Allocation size overflow");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const size_t total_size = count * size;
|
||||
void* block = _glfw.allocator.allocate(total_size, _glfw.allocator.user);
|
||||
if (!block)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue