summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--unix/tclUnixSock.c22
2 files changed, 11 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index c94cb35..c840c29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
*/