From 889040e20d86da14aab372203ebaa91dda5db6f2 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Wed, 5 Sep 2018 18:16:37 +0530 Subject: cluster/dht: Initialise pointers to null Use calloc in dht_layouts_init so to as to prevent dht_init from attempting to free invalid memory in case of failure. There are other ways to do this (set first failure to null and break there when cleaning up) but I prefer having all pointers initialized to null. This is a one time operation so it should not be too expensive. Change-Id: Ie22246047448f1cae971d48fa5aaf2efcaeb42c0 fixes: bz#1625643 Signed-off-by: N Balachandran --- xlators/cluster/dht/src/dht-layout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index 6d9d4e693ff..97b98e01451 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -201,8 +201,8 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf) if (!conf) goto out; - conf->file_layouts = GF_MALLOC (conf->subvolume_cnt - * sizeof (dht_layout_t *), + conf->file_layouts = GF_CALLOC (conf->subvolume_cnt, + sizeof (dht_layout_t *), gf_dht_mt_dht_layout_t); if (!conf->file_layouts) { goto out; -- cgit