diff options
author | rmax <rmax> | 2010-10-12 11:37:22 (GMT) |
---|---|---|
committer | rmax <rmax> | 2010-10-12 11:37:22 (GMT) |
commit | 92e0bb7cedfa98e6c502bd81e5ae4f9f0a62cfea (patch) | |
tree | 04daec902e966c3bf507f4dc7b408c961296f71c | |
parent | 88ac6d1bd8bf253aaca06731296ed6c96410decb (diff) | |
download | tcl-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].
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | unix/tclUnixSock.c | 22 |
2 files changed, 11 insertions, 16 deletions
@@ -1,3 +1,8 @@ +2010-10-12 Reinhard Max <max@suse.de> + + * unix/tclUnixSock.c (CreateClientSocket): Fix a memleak and + refactor the calls to freeaddrinfo() [Bug #3084338]. + 2010-10-12 Jan Nijtmans <nijtmans@users.sf.net> * win/tclWin32Dll.c: Eliminate many tclWinProcs-> indirect calls, which 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. */ |