From 273d609bac91b6e373dc4a7b08a00a4d48bda40c Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 10 Feb 2016 21:21:08 +0100 Subject: [PATCH] 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. --- src/core/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/mem.c b/src/core/mem.c index ffc0c292..9ca9e3c4 100644 --- a/src/core/mem.c +++ b/src/core/mem.c @@ -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; }