diff options
author | shishir gowda <shishirng@gluster.com> | 2010-11-02 04:05:07 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2010-11-02 06:02:58 -0700 |
commit | 8ca96737a92a032334b745ffb6f4b872b8359fb0 (patch) | |
tree | d79dcac988b14c893a2a1332ce065ffda47c4326 | |
parent | c4ef206dd37a9e6c547caae5bf10b19d336dde8d (diff) |
Cli memory leak fix for tmp_list in cli_cmd_volume_add_brick_parsev3.1.1qa4
Signed-off-by: shishir gowda <shishirng@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 2047 ()
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2047
-rw-r--r-- | cli/src/cli-cmd-parser.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index aa108f3f2d9..3780abefe5f 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -447,6 +447,7 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, char *host_name = NULL; char *tmp = NULL; char *freeptr = NULL; + char *free_list_ptr = NULL; GF_ASSERT (words); GF_ASSERT (options); @@ -547,6 +548,7 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, GF_FREE (freeptr); tmp_list = strdup(brick_list+1); + free_list_ptr = tmp_list; j = 0; while(( brick_count != 0) && (j < brick_count)) { strtok_r (tmp_list, " ", &tmpptr); @@ -554,6 +556,8 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, ret = -1; cli_out ("Found duplicate" " exports %s",words[brick_index]); + if (free_list_ptr) + free (free_list_ptr); goto out; } tmp_list = tmpptr; @@ -573,6 +577,8 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, if (ret) goto out; */ + if (free_list_ptr) + free (free_list_ptr); } ret = dict_set_str (dict, "bricks", brick_list); if (ret) @@ -591,8 +597,6 @@ out: if (dict) dict_destroy (dict); } - if (tmp_list) - free (tmp_list); return ret; } |