utils: detect overflow in memdup() Signed-off-by: Ran Benita <ran234@gmail.com>
diff --git a/src/utils.h b/src/utils.h
index 878c2ac..0198f07 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -99,7 +99,7 @@ strempty(const char *s)
static inline void *
memdup(const void *mem, size_t nmemb, size_t size)
{
- void *p = malloc(nmemb * size);
+ void *p = calloc(nmemb, size);
if (p)
memcpy(p, mem, nmemb * size);
return p;