nwrap: Use calloc in nwrap_libc_init()
authorAndreas Schneider <asn@samba.org>
Wed, 31 Oct 2018 10:10:08 +0000 (11:10 +0100)
committerAndreas Schneider <asn@samba.org>
Wed, 31 Oct 2018 12:21:59 +0000 (13:21 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
src/nss_wrapper.c

index dd16fe6d554ad881fc3f539af588c99e4d2b9db1..7023a4fdcc39fc15b2ad84a903a442d2067711aa 100644 (file)
@@ -1512,19 +1512,17 @@ static bool nwrap_module_init(const char *name,
 
 static void nwrap_libc_init(struct nwrap_main *r)
 {
-       r->libc = malloc(sizeof(struct nwrap_libc));
+       r->libc = calloc(1, sizeof(struct nwrap_libc));
        if (r->libc == NULL) {
                printf("Failed to allocate memory for libc");
                exit(-1);
        }
-       ZERO_STRUCTP(r->libc);
 
-       r->libc->fns = malloc(sizeof(struct nwrap_libc_fns));
+       r->libc->fns = calloc(1, sizeof(struct nwrap_libc_fns));
        if (r->libc->fns == NULL) {
                printf("Failed to allocate memory for libc functions");
                exit(-1);
        }
-       ZERO_STRUCTP(r->libc->fns);
 }
 
 static void nwrap_backend_init(struct nwrap_main *r)