utils: detect overflow in memdup()

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-04-22 14:34:57 +03:00
parent 95aabeecb1
commit 00f084b6ec
1 changed files with 1 additions and 1 deletions

View File

@ -99,7 +99,7 @@ strempty(const char *s)
static inline void * static inline void *
memdup(const void *mem, size_t nmemb, size_t size) memdup(const void *mem, size_t nmemb, size_t size)
{ {
void *p = malloc(nmemb * size); void *p = calloc(nmemb, size);
if (p) if (p)
memcpy(p, mem, nmemb * size); memcpy(p, mem, nmemb * size);
return p; return p;