summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2004-06-17 22:13:00 (GMT)
committerdgp <dgp@users.sourceforge.net>2004-06-17 22:13:00 (GMT)
commita606a3cc64631df1467dbd8c5abaf6a517bd7ab3 (patch)
treec4ef739dd82f206cff3f2ba10fb4bcc8bf74d839
parent22f8732e9a6d0f120c78eb2b579c1ecf4ebf0d52 (diff)
downloadtcl-a606a3cc64631df1467dbd8c5abaf6a517bd7ab3.zip
tcl-a606a3cc64631df1467dbd8c5abaf6a517bd7ab3.tar.gz
tcl-a606a3cc64631df1467dbd8c5abaf6a517bd7ab3.tar.bz2
Relaxed panic condition on overwrite of default library path to accept
double right of the same value. Needed to support Tk_Main's call order (Tcl_CreateInterp before Tcl_FindExecutable).
-rw-r--r--win/tclWinInit.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 9f6d50f..e9b1255 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclWinInit.c,v 1.55 2004/06/17 21:43:56 dgp Exp $
+ * RCS: @(#) $Id: tclWinInit.c,v 1.56 2004/06/17 22:13:00 dgp Exp $
*/
#include "tclWinInt.h"
@@ -153,6 +153,7 @@ static void
SetDefaultLibraryDir(directory)
Tcl_Obj *directory;
{
+ int numBytes = 0;
CONST char *bytes;
Tcl_Obj **savedDirectoryPtr = (Tcl_Obj **)
Tcl_GetThreadData(&defaultLibraryDirKey, (int)sizeof(Tcl_Obj *));
@@ -170,15 +171,20 @@ SetDefaultLibraryDir(directory)
/* No Mutex protection, as the only caller is already in TclpInitLock */
+ bytes = Tcl_GetStringFromObj(directory, &numBytes);
if (NULL == defaultLibraryDir) {
/* First call from any thread; set up exit handler */
Tcl_CreateExitHandler(FreeDefaultLibraryDir, NULL);
} else {
- Tcl_Panic("Double initialization of DefaultLibraryDir?!");
+ if ((defaultLibraryDirLength != numBytes)
+ || (0 != strcmp(defaultLibraryDir, bytes, numBytes))) {
+ Tcl_Panic("Attempt to overwrite defaultLibraryDir");
+ }
+ return;
}
- bytes = Tcl_GetStringFromObj(directory, &defaultLibraryDirLength);
- defaultLibraryDir = ckalloc((unsigned int) defaultLibraryDirLength+1);
- memcpy(defaultLibraryDir, bytes, (unsigned int) defaultLibraryDirLength+1);
+ defaultLibraryDirLength = numBytes;
+ defaultLibraryDir = ckalloc((unsigned int) numBytes + 1);
+ memcpy(defaultLibraryDir, bytes, (unsigned int) numBytes + 1);
}
/*
@@ -212,7 +218,10 @@ GetDefaultLibraryDir()
if (NULL == defaultLibraryDir) {
/*
* Careful here. This may be bogus, calling TclpInitLibraryPath
- * when not in TclpInitLock. OTOH, this branch shouldn't happen.
+ * when not in TclpInitLock.
+ *
+ * This path is taken by wish because it calls Tcl_CreateInterp
+ * before it calls Tcl_FindExecutable.
*/
TclpInitLibraryPath(NULL);
if (NULL != *savedDirectoryPtr) {