From cebc5223abdec2d1d1862960ff0c473850eba134 Mon Sep 17 00:00:00 2001 From: the xhr Date: Wed, 25 Aug 2021 14:04:07 +0200 Subject: Replace malloc() in xmalloc() with calloc() so that all memory get zero'ed out at allocation time. Remove a then useless memset --- request.c | 2 -- util.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/request.c b/request.c index 609f368..1cc20ca 100644 --- a/request.c +++ b/request.c @@ -39,8 +39,6 @@ uridecode(const char *request) const char *p; char *pt; - memset(temp, 0, strlen(request)+1); - p = request; pt = temp; diff --git a/util.c b/util.c index 1f836d9..f6494db 100644 --- a/util.c +++ b/util.c @@ -27,7 +27,7 @@ xmalloc(size_t size) if (size == 0) fatal("xmalloc: zero size"); - ptr = malloc(size); + ptr = calloc(1, size); if (ptr == NULL) fatal("xmalloc: out of memory (allocating %zu bytes)", size); return ptr; -- cgit v1.2.3