utils: detect overflow in memdup()
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
95aabeecb1
commit
00f084b6ec
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue