[WINESYNC] msvcrt: Handle overflow in calloc().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 50dd4b892825c75db35cd1f378291b51fa782f3e by Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Timo Kreuzer 2016-04-27 11:11:49 +03:00
parent 977e236102
commit 1d6ec8555d

View file

@ -418,7 +418,15 @@ size_t CDECL _aligned_msize(void *p, MSVCRT_size_t alignment, MSVCRT_size_t offs
*/
void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size)
{
return msvcrt_heap_alloc(HEAP_ZERO_MEMORY, count*size);
MSVCRT_size_t bytes = count*size;
if (size && bytes / size != count)
{
*MSVCRT__errno() = MSVCRT_ENOMEM;
return NULL;
}
return msvcrt_heap_alloc(HEAP_ZERO_MEMORY, bytes);
}
/*********************************************************************