glusterd: Resolve memory leak in get-state command

In gluster get-state volumeoptions command there was some amount of leak
observed. This fix resolves the identified leaks.

Change-Id: Ibde5743d1136fa72c531d48bb1b0b5da0c0b82a1
fixes: bz#1667779
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
This commit is contained in:
Mohit Agrawal
2019-01-21 09:12:30 +05:30
committed by Atin Mukherjee
parent 11aaecccad
commit 5903111ad2

View File

@ -13148,6 +13148,7 @@ glusterd_get_default_val_for_volopt(dict_t *ctx, gf_boolean_t all_opts,
char dict_key[50] = "";
int keylen;
gf_boolean_t key_found = _gf_false;
gf_boolean_t get_value_vme = _gf_false;
glusterd_conf_t *priv = NULL;
dict_t *vol_dict = NULL;
@ -13170,6 +13171,7 @@ glusterd_get_default_val_for_volopt(dict_t *ctx, gf_boolean_t all_opts,
if (!all_opts && strcmp(vme->key, input_key))
continue;
key_found = _gf_true;
get_value_vme = _gf_false;
/* First look for the key in the priv->opts for global option
* and then into vol_dict, if its not present then look for
* translator default value */
@ -13184,6 +13186,7 @@ glusterd_get_default_val_for_volopt(dict_t *ctx, gf_boolean_t all_opts,
def_val = vme->value;
} else {
ret = glusterd_get_value_for_vme_entry(vme, &def_val);
get_value_vme = _gf_true;
if (!all_opts && ret)
goto out;
else if (ret == -2)
@ -13199,6 +13202,8 @@ glusterd_get_default_val_for_volopt(dict_t *ctx, gf_boolean_t all_opts,
"Failed to "
"set %s in dictionary",
vme->key);
if (get_value_vme)
GF_FREE(def_val);
goto out;
}
sprintf(dict_key, "value%d", count);
@ -13208,8 +13213,13 @@ glusterd_get_default_val_for_volopt(dict_t *ctx, gf_boolean_t all_opts,
"Failed to "
"set %s for key %s in dictionary",
def_val, vme->key);
if (get_value_vme)
GF_FREE(def_val);
goto out;
}
if (get_value_vme)
GF_FREE(def_val);
def_val = NULL;
if (!all_opts)
break;