diff options
author | Mohit Agrawal <moagrawal@redhat.com> | 2019-01-21 09:12:30 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2019-01-21 11:10:58 +0000 |
commit | 5903111ad21cb937258c0fda24ea7dec466347b4 (patch) | |
tree | 088a5de9b5c5f5114aa2290fe47e7b2bfb817b0c /xlators/mgmt/glusterd/src/glusterd-utils.c | |
parent | 11aaecccad03d5803dc7be63c3e36af75da8126d (diff) |
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>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-utils.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index de675f22761..fd6e360a730 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -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; |