summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2010-09-09 05:56:59 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-09 05:23:39 -0700
commitc1f4f9ba17fd40ef9c726a9599f3122f29ef0092 (patch)
tree91b052cd95ef4a868c578a9a322f46e735aecdf2 /xlators
parent6ee84e00f0d96e292163ebad86b2e7521776dca1 (diff)
free the tmp string allocated while getting brick information
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1580 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1580
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index d078b00c9..ab86041d8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -628,14 +628,20 @@ glusterd_brickinfo_from_brick (char *brick,
char *hostname = NULL;
char *path = NULL;
char *tmp = NULL;
+ char *tmpstr = NULL;
GF_ASSERT (brick);
GF_ASSERT (brickinfo);
- tmp = strdup (brick);
+ tmp = gf_strdup (brick);
+ if (!tmp) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "Out of memory");
+ goto out;
+ }
- hostname = strtok (tmp, ":");
- path = strtok (NULL, ":");
+ hostname = strtok_r (tmp, ":", &tmpstr);
+ path = strtok_r (NULL, ":", &tmpstr);
GF_ASSERT (hostname);
GF_ASSERT (path);
@@ -652,6 +658,8 @@ glusterd_brickinfo_from_brick (char *brick,
ret = 0;
out:
+ if (tmp)
+ GF_FREE (tmp);
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}