mem.c: Fix unintended sign extension (found by Coverity)

sign_extension: Suspicious implicit sign extension: count with type unsigned short (16 bits, unsigned) is promoted in count * size to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If count * size is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.
This commit is contained in:
Dirk Ziegelmeier 2016-02-10 21:21:08 +01:00
parent 288b4564e4
commit 273d609bac

View File

@ -674,7 +674,7 @@ void *mem_calloc(mem_size_t count, mem_size_t size)
p = mem_malloc(count * size);
if (p) {
/* zero the memory */
memset(p, 0, count * size);
memset(p, 0, (size_t)count * (size_t)size);
}
return p;
}