diff options
author | Amar Tumballi <amar@gluster.com> | 2010-09-09 07:18:50 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-09 12:19:47 -0700 |
commit | 4aada05a7a2b21d4c5275812a6e8f838e3a10512 (patch) | |
tree | 76931da6a1f892633933abbb840dae32ebeefdab /rpc/rpc-lib/src/rpcsvc.c | |
parent | c1d8e31ad0b772149620465e79774cbf7b048d41 (diff) |
rpc/rpcsvc: fix invalid free in rpcsvc_create_listeners.
Sending on behalf of Raghavendra G
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 513 (Introduce 0 copy rdma)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=513
Diffstat (limited to 'rpc/rpc-lib/src/rpcsvc.c')
-rw-r--r-- | rpc/rpc-lib/src/rpcsvc.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c index 5da6705a681..5f6f6b31053 100644 --- a/rpc/rpc-lib/src/rpcsvc.c +++ b/rpc/rpc-lib/src/rpcsvc.c @@ -1860,12 +1860,12 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name) int32_t ret = -1, count = 0; data_t *data = NULL; char *str = NULL, *ptr = NULL, *transport_name = NULL; - char *transport_type = NULL, *saveptr = NULL; + char *transport_type = NULL, *saveptr = NULL, *tmp = NULL; if ((svc == NULL) || (options == NULL) || (name == NULL)) { goto out; } - + data = dict_get (options, "transport-type"); if (data == NULL) { gf_log (GF_RPCSVC, GF_LOG_DEBUG, @@ -1896,22 +1896,23 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name) ptr = strtok_r (str, ",", &saveptr); while (ptr != NULL) { - ptr = gf_strdup (ptr); - if (ptr == NULL) { + tmp = gf_strdup (ptr); + if (tmp == NULL) { gf_log (GF_RPCSVC, GF_LOG_ERROR, "out of memory"); goto out; } - ret = asprintf (&transport_name, "%s.%s", ptr, name); + ret = asprintf (&transport_name, "%s.%s", tmp, name); if (ret == -1) { goto out; } - ret = dict_set_dynstr (options, "transport-type", ptr); + ret = dict_set_dynstr (options, "transport-type", tmp); if (ret == -1) { goto out; } + tmp = NULL; ptr = strtok_r (NULL, ",", &saveptr); ret = rpcsvc_create_listener (svc, options, transport_name); @@ -1922,8 +1923,6 @@ rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name) count++; } - ptr = NULL; - ret = dict_set_dynstr (options, "transport-type", transport_type); if (ret == -1) { goto out; @@ -1940,8 +1939,8 @@ out: GF_FREE (transport_type); } - if (ptr != NULL) { - GF_FREE (ptr); + if (tmp != NULL) { + GF_FREE (tmp); } return count; |