From e2fe81ae9ab6e3fafa0b5b190a529193c1df91b0 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 23 Nov 2014 21:43:25 +0100 Subject: 33785: Fix leaks of desthost in ztcp Found by coverity. --- Src/Modules/tcp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Src') diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index 3f92050ae..0d9522047 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -623,6 +623,7 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) zthost = zsh_getipnodebyname(desthost, AF_INET, 0, &herrno); if (!zthost || errflag) { zwarnnam(nam, "host resolution failure: %s", desthost); + zsfree(desthost); return 1; } @@ -630,6 +631,7 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) if (!sess) { zwarnnam(nam, "unable to allocate a TCP session slot"); + zsfree(desthost); return 1; } @@ -665,6 +667,8 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) sess->fd = redup(sess->fd, targetfd); if (sess->fd < 0) { zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); + zsfree(desthost); + tcp_close(sess); return 1; } } -- cgit 1.4.1