mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-30 15:15:05 +00:00
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:
parent
288b4564e4
commit
273d609bac
@ -674,7 +674,7 @@ void *mem_calloc(mem_size_t count, mem_size_t size)
|
|||||||
p = mem_malloc(count * size);
|
p = mem_malloc(count * size);
|
||||||
if (p) {
|
if (p) {
|
||||||
/* zero the memory */
|
/* zero the memory */
|
||||||
memset(p, 0, count * size);
|
memset(p, 0, (size_t)count * (size_t)size);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user