[sheepdog] [PATCH stable-0.7 1/4] sheep: fix memory leak at create_client()
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Tue Dec 17 09:52:37 CET 2013
From: Ryusuke Konishi <konishi.ryusuke at lab.ntt.co.jp>
The current create_client function does not free client_info structure
when getpeername() failed.
This fixes the leak bug.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke at lab.ntt.co.jp>
Reviewed-by:Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
sheep/request.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sheep/request.c b/sheep/request.c
index bd69ea9..8ddc252 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -751,8 +751,10 @@ static struct client_info *create_client(int fd, struct cluster_info *cluster)
if (!ci)
return NULL;
- if (getpeername(fd, (struct sockaddr *)&from, &namesize))
+ if (getpeername(fd, (struct sockaddr *)&from, &namesize)) {
+ free(ci);
return NULL;
+ }
switch (from.ss_family) {
case AF_INET:
--
1.7.10.4
More information about the sheepdog
mailing list