From: Ryusuke Konishi <[email protected]>

The current create_client function does not free client_info structure
when getpeername() failed.

This fixes the leak bug.

Signed-off-by: Ryusuke Konishi <[email protected]>
Reviewed-by:Hitoshi Mitake <[email protected]>
Signed-off-by: Liu Yuan <[email protected]>
---
 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

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to