From 4ac61e7354d0c79e235e1b3be269a989ee0a83e6 Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Thu, 23 Jan 2014 15:37:09 -0600 Subject: cluster/dht: goto statements may cause loop exit before memory is freed. Memory is allocated at the top of the while loop via a call to gf_strdup(), but there are several goto calls that exit the loop, and the memory is not freed before each of those calls to goto. This fix moves the final call to GF_FREE() higher in the loop so that the memory is correctly freed. Two variables, dup_str and str_tmp1, point to portions of the allocated memory. Neither are used past the final call to GF_FREE( dup_str ). BUG: 789278 CID: 1124780 Change-Id: Id24b80cdbfd8b8855c80fffec63d7fce98cbed4a Signed-off-by: Christopher R. Hertel Reviewed-on: http://review.gluster.org/6771 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/dht/src/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c index d3ea90ba8..2717ce975 100644 --- a/xlators/cluster/dht/src/switch.c +++ b/xlators/cluster/dht/src/switch.c @@ -670,6 +670,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf, GF_FREE (dup_str); continue; } + GF_FREE (dup_str); memcpy (switch_opt->path_pattern, pattern, strlen (pattern)); if (childs) { dup_childs = gf_strdup (childs); @@ -726,7 +727,6 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf, "option in unify volume. Exiting"); goto err; } - GF_FREE (dup_str); /* Link it to the main structure */ if (switch_buf) { -- cgit