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 <crh@redhat.com>
Reviewed-on: http://review.gluster.org/6771
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Christopher R. Hertel 2014-01-23 15:37:09 -06:00 committed by Vijay Bellur
parent 3340a896a1
commit 4ac61e7354

View File

@ -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) {