summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 d078b00c98e..ab86041d8c1 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;
}