From 381128364e3dfb19a61d0e603aa69192edc66a84 Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Thu, 21 Jan 2021 19:35:57 +0530 Subject: [PATCH] Replace malloc + memset with calloc. Fixes an overflow warning from gcc with '-Wstringop-overflow' on NetBSD-current. --- src/core/net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/net.c b/src/core/net.c index f7e1c3ac..baa0157c 100644 --- a/src/core/net.c +++ b/src/core/net.c @@ -263,12 +263,11 @@ static struct addrinfo *janet_get_addrinfo(Janet *argv, int32_t offset, int sock #ifndef JANET_WINDOWS if (janet_keyeq(argv[offset], "unix")) { const char *path = janet_getcstring(argv, offset + 1); - struct sockaddr_un *saddr = malloc(sizeof(struct sockaddr_un)); + struct sockaddr_un *saddr = calloc(1, sizeof(struct sockaddr_un)); if (saddr == NULL) { JANET_OUT_OF_MEMORY; } saddr->sun_family = AF_UNIX; - memset(&saddr->sun_path, 0, 108); #ifdef JANET_LINUX if (path[0] == '@') { saddr->sun_path[0] = '\0';