From 8690388bc7b3fe92c5dfc43a7173d5f05137e9cd Mon Sep 17 00:00:00 2001 From: "Bala.FA" Date: Thu, 21 Nov 2013 17:16:39 +0530 Subject: 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: I3b638ec289d5b167c6e752ef1ba41f41efacb9da Signed-off-by: Bala.FA Reviewed-on: http://review.gluster.org/6330 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 501be66f8..e9437057a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3291,6 +3291,12 @@ glusterd_op_modify_op_ctx (glusterd_op_t op, void *ctx) snprintf (key, sizeof (key), "brick%d.peerid", i); 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) { @@ -3346,6 +3352,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++) { @@ -3356,8 +3363,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); + } } } } -- cgit