From abf28c8fd12f662f32c1a81f84620f562de8f14b Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 15 Sep 2010 00:27:10 +0000 Subject: memory leak fixes. - free memory allocated by libc when decoding request arguments in server and reply in client. - free memory allocated to saved_frames during connection cleanup. - free memory allocated for transport name while creating listeners. Signed-off-by: Raghavendra G Signed-off-by: Vijay Bellur BUG: 1438 (memory leaks) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1438 --- xlators/protocol/server/src/server-handshake.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'xlators/protocol/server/src/server-handshake.c') diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 98ec18cc2..b148f0669 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -355,6 +355,7 @@ server_setvolume (rpcsvc_request_t *req) int32_t op_errno = EINVAL; int32_t fop_version = 0; int32_t mgmt_version = 0; + char *buf = NULL; params = dict_new (); reply = dict_new (); @@ -369,7 +370,15 @@ server_setvolume (rpcsvc_request_t *req) config_params = dict_copy_with_ref (this->options, NULL); conf = this->private; - ret = dict_unserialize (args.dict.dict_val, args.dict.dict_len, ¶ms); + buf = memdup (args.dict.dict_val, args.dict.dict_len); + if (buf == NULL) { + gf_log (this->name, GF_LOG_ERROR, "out of memory"); + op_ret = -1; + op_errno = ENOMEM; + goto fail; + } + + ret = dict_unserialize (buf, args.dict.dict_len, ¶ms); if (ret < 0) { ret = dict_set_str (reply, "ERROR", "Internal error: failed to unserialize " @@ -385,6 +394,9 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } + params->extra_free = buf; + buf = NULL; + ret = dict_get_str (params, "process-uuid", &process_uuid); if (ret < 0) { ret = dict_set_str (reply, "ERROR", @@ -622,6 +634,10 @@ fail: dict_unref (reply); dict_unref (config_params); + if (buf) { + GF_FREE (buf); + } + return 0; } -- cgit