summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorSunny Kumar <sunkumar@redhat.com>2018-12-07 10:53:44 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-12-10 05:46:00 +0000
commit74c72d0dd9a47b842f4247d939b64089a6fb8e43 (patch)
tree12b3bc6f504662139cbcc3e617180f4f93aabab1 /cli
parent6e92171117c73d7a8901800299446a131e54b597 (diff)
cli : fix memory leak in cli-cmd-volume.c
This patch fixes ememory leak reported by ASan. Tracebacks: Direct leak of 84 byte(s) in 1 object(s) allocated from: #0 0x7f71ea107848 in __interceptor_malloc (/lib64/libasan.so.5+0xef848) #1 0x7f71e9e2ac49 in __gf_malloc ./libglusterfs/src/mem-pool.c:136 #2 0x7f71e9e2b4bb in gf_vasprintf ./libglusterfs/src/mem-pool.c:236 #3 0x7f71e9e2b68a in gf_asprintf ./libglusterfs/src/mem-pool.c:256 #4 0x41e8ec in cli_cmd_bitrot_cbk ./cli/src/cli-cmd-volume.c:1847 #5 0x410b39 in cli_cmd_process ./cli/src/cli-cmd.c:137 #6 0x40fe9d in cli_batch ./cli/src/input.c:29 #7 0x7f71e989558d in start_thread (/lib64/libpthread.so.0+0x858d) updates: bz#1633930 Change-Id: I8977e45add742e67047291f398f0ee79eb09afe4 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 7ce5621cdb4..8df7c2377bc 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1796,6 +1796,7 @@ cli_cmd_bitrot_cbk(struct cli_state *state, struct cli_cmd_word *word,
int event_type = -1;
char *tmp = NULL;
char *events_str = NULL;
+ char *volname = NULL;
#endif
ret = cli_cmd_bitrot_parse(words, wordcount, &options);
@@ -1841,10 +1842,9 @@ out:
if (ret1)
cmd_type = -1;
else {
- ret1 = dict_get_str(options, "volname", &tmp);
+ ret1 = dict_get_str(options, "volname", &volname);
if (ret1)
- tmp = "";
- gf_asprintf(&events_str, "name=%s", tmp);
+ volname = "";
}
switch (cmd_type) {
@@ -1862,21 +1862,21 @@ out:
ret1 = dict_get_str(options, "scrub-throttle-value", &tmp);
if (ret1)
tmp = "";
- gf_asprintf(&events_str, "%s;value=%s", events_str, tmp);
+ gf_asprintf(&events_str, "name=%s;value=%s", volname, tmp);
break;
case GF_BITROT_OPTION_TYPE_SCRUB_FREQ:
event_type = EVENT_BITROT_SCRUB_FREQ;
ret1 = dict_get_str(options, "scrub-frequency-value", &tmp);
if (ret1)
tmp = "";
- gf_asprintf(&events_str, "%s;value=%s", events_str, tmp);
+ gf_asprintf(&events_str, "name=%s;value=%s", volname, tmp);
break;
case GF_BITROT_OPTION_TYPE_SCRUB:
event_type = EVENT_BITROT_SCRUB_OPTION;
ret1 = dict_get_str(options, "scrub-value", &tmp);
if (ret1)
tmp = "";
- gf_asprintf(&events_str, "%s;value=%s", events_str, tmp);
+ gf_asprintf(&events_str, "name=%s;value=%s", volname, tmp);
break;
default:
break;