From 7bef47d44562d1078457fd681f39a40e54d43897 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 24 Jul 2006 13:43:13 +0000 Subject: * win/tclWinSock.c: Correct un-initialized Tcl_DString. Thanks to afredd. [Bug 1518166] --- ChangeLog | 6 ++++++ win/tclWinSock.c | 32 +++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6be728c..f1ceb9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ +2006-07-24 Don Porter + + * win/tclWinSock.c: Correct un-initialized Tcl_DString. Thanks + to afredd. [Bug 1518166] + 2006-07-21 Miguel Sofer + * generic/tclExecute.c: * tests/execute.test (execute-9.1): dgp's fix for [Bug 1522803]. diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 488618d..717b42a 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.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: tclWinSock.c,v 1.54 2006/04/05 16:32:45 dgp Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.55 2006/07/24 13:43:14 dgp Exp $ */ #include "tclWinInt.h" @@ -2551,21 +2551,23 @@ InitializeHostName( Tcl_UtfToLower(Tcl_WinTCharToUtf((TCHAR *) wbuf, -1, &ds)); - } else if (TclpHasSockets(NULL) == TCL_OK) { - /* - * Buffer length of 255 copied slavishly from previous version of this - * routine. Presumably there's a more "correct" macro value for a - * properly sized buffer for a gethostname() call. Maintainers are - * welcome to supply it. - */ - + } else { Tcl_DStringInit(&ds); - Tcl_DStringSetLength(&ds, 255); - if (winSock.gethostname(Tcl_DStringValue(&ds), - Tcl_DStringLength(&ds)) == 0) { - Tcl_DStringSetLength(&ds, 0); - } else { - Tcl_DStringSetLength(&ds, strlen(Tcl_DStringValue(&ds))); + if (TclpHasSockets(NULL) == TCL_OK) { + /* + * Buffer length of 255 copied slavishly from previous version + * of this routine. Presumably there's a more "correct" macro + * value for a properly sized buffer for a gethostname() call. + * Maintainers are welcome to supply it. + */ + + Tcl_DStringSetLength(&ds, 255); + if (winSock.gethostname(Tcl_DStringValue(&ds), + Tcl_DStringLength(&ds)) == 0) { + Tcl_DStringSetLength(&ds, 0); + } else { + Tcl_DStringSetLength(&ds, strlen(Tcl_DStringValue(&ds))); + } } } -- cgit v0.12