Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Fix leaks of desthost in ztcp
- X-seq: zsh-workers 33785
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: Fix leaks of desthost in ztcp
- Date: Sun, 23 Nov 2014 22:07:00 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=rTQDg++5fEqVKh87dh+Tayfv56GjvfLW9Vez1mema24=; b=SCutvdAFu/6GK/vfWn2ClMa7U17iEpptAYgTd9WCu4iXmdyUWOHFqQ8MeMDlyFK6n1 NQewamsc8wDAMTGjiGfBZcU9c08sxP6MDjaLhIx3vJuUYed1p1s+c561Ap3DWkumKB5Y M1hmAsVpdBvdoCGVetgIGYLSdNY+dNNDsLRMtjB3sRBiN8TlpP4Mai1CyBSb7IpO67KT DXHgBECbIgDDBsyhZT1e26BjpsPa5irPBO6znDwa5wj1RdfK55Ukc01g2jzEnpum6o1I VE38NA7f4zqLmqIF99iWUOU/f9CbL71KdKB2qtelUDg9GpX1ndgSYCumZfvj1rIX4DID NcfA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Found by coverity. Is that tcp_close right too? It's closed in another
error case nearby so I'm pretty sure it is.
---
Src/Modules/tcp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index 3f92050..0d95220 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;
}
}
--
2.2.0-rc0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author