diff options
author | Bala.FA <barumuga@redhat.com> | 2013-11-21 17:16:39 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-11-26 11:51:34 -0800 |
commit | e412da34e927737efae711740191c59749214e9a (patch) | |
tree | d81d6c01fd0051698ed6c474e44f58ce186cbe11 /xlators | |
parent | 837422858c2e4ab447879a4141361fd382645406 (diff) |
cli: use proper copy to set node-name
Previously node-name is set to point to node-uuid which could cause
memory leak. This is fixed by having memory copy of node-uuid.
BUG: 1012296
Change-Id: I4a7123771e2d8c31c5db4f78d022a9f4fbfc2667
Signed-off-by: Bala.FA <barumuga@redhat.com>
Reviewed-on: http://review.gluster.org/6331
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index f7950da530a..e4ff10dad22 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3156,6 +3156,7 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) { char key[1024]; char *uuid_str = NULL; + char *uuid = NULL; int i; for (i = 1; i <= count; i++) { @@ -3166,8 +3167,18 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "node-name-%d", i); - ret = dict_set_str (op_ctx, key, - uuid_str); + uuid = gf_strdup (uuid_str); + if (!uuid) { + gf_log (this->name, GF_LOG_DEBUG, + "unable to create dup of" + " uuid_str"); + continue; + } + ret = dict_set_dynstr (op_ctx, key, + uuid); + if (ret != 0) { + GF_FREE (uuid); + } } } } |