summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixSock.c
diff options
context:
space:
mode:
authorrmax <rmax>2010-10-12 11:37:22 (GMT)
committerrmax <rmax>2010-10-12 11:37:22 (GMT)
commit92e0bb7cedfa98e6c502bd81e5ae4f9f0a62cfea (patch)
tree04daec902e966c3bf507f4dc7b408c961296f71c /unix/tclUnixSock.c
parent88ac6d1bd8bf253aaca06731296ed6c96410decb (diff)
downloadtcl-92e0bb7cedfa98e6c502bd81e5ae4f9f0a62cfea.zip
tcl-92e0bb7cedfa98e6c502bd81e5ae4f9f0a62cfea.tar.gz
tcl-92e0bb7cedfa98e6c502bd81e5ae4f9f0a62cfea.tar.bz2
* unix/tclUnixSock.c (CreateClientSocket): Fix a memleak and
refactor the calls to freeaddrinfo() [Bug #3084338].
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r--unix/tclUnixSock.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index ba3d0d0..6c434ab 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixSock.c,v 1.27 2010/09/28 15:13:55 rmax Exp $
+ * RCS: @(#) $Id: tclUnixSock.c,v 1.28 2010/10/12 11:37:22 rmax Exp $
*/
#include "tclInt.h"
@@ -867,7 +867,7 @@ CreateClientSocket(
* attempt to do an async connect. Otherwise
* do a synchronous connect or bind. */
{
- int status = 0, connected = 0, sock = -1;
+ int status = -1, connected = 0, sock = -1;
struct addrinfo *addrlist = NULL, *addrPtr;
/* Socket address */
struct addrinfo *myaddrlist = NULL, *myaddrPtr;
@@ -968,14 +968,11 @@ CreateClientSocket(
status = TclUnixSetBlockingMode(sock, TCL_MODE_BLOCKING);
}
+error:
+ freeaddrinfo(addrlist);
+ freeaddrinfo(myaddrlist);
+
if (status < 0) {
- error:
- if (addrlist != NULL) {
- freeaddrinfo(addrlist);
- }
- if (myaddrlist != NULL) {
- freeaddrinfo(myaddrlist);
- }
if (interp != NULL) {
Tcl_AppendResult(interp, "couldn't open socket: ",
Tcl_PosixError(interp), NULL);
@@ -989,13 +986,6 @@ CreateClientSocket(
return NULL;
}
- if (addrlist == NULL) {
- freeaddrinfo(addrlist);
- }
- if (myaddrlist == NULL) {
- freeaddrinfo(myaddrlist);
- }
-
/*
* Allocate a new TcpState for this socket.
*/