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>
This commit is contained in:
parent
6e92171117
commit
74c72d0dd9
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user