From 5fb60ca150efbf9072dd7b2de13362c8cc4daa1b Mon Sep 17 00:00:00 2001 From: Ira Cooper Date: Tue, 11 Feb 2014 07:05:29 -0500 Subject: glusterd: Free dup_value when error path is taken. When the error path is taken here, the data that was allocated for dup_value is never freed. This patch frees it. Thanks to Kaleb Keithley for his suggestions on how to fix this. Change-Id: Iad88b9ab035602d15961b46c4954d54d54e0d65e CID: 1124705 BUG: 789278 Signed-off-by: Ira Cooper Reviewed-on: http://review.gluster.org/6780 Reviewed-by: Krishnan Parthasarathi Reviewed-by: Kaleb KEITHLEY Tested-by: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'xlators/mgmt/glusterd/src') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 385f14e9e..e3ae369e4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1721,10 +1721,6 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict) if (ret) goto out; - dup_value = gf_strdup (value); - if (!dup_value) - goto out; - ret = glusterd_store_options (this, dup_opt); if (ret) goto out; @@ -1739,10 +1735,18 @@ glusterd_op_set_all_volume_options (xlator_t *this, dict_t *dict) else next_version = NULL; + dup_value = gf_strdup (value); + if (!dup_value) + goto out; + ret = dict_set_dynstr (conf->opts, key, dup_value); if (ret) goto out; + else + dup_value = NULL; /* Protect the allocation from GF_FREE */ + out: + GF_FREE (dup_value); GF_FREE (key_fixed); if (dup_opt) dict_unref (dup_opt); -- cgit