diff options
author | dgp <dgp@users.sourceforge.net> | 2001-01-04 21:30:49 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2001-01-04 21:30:49 (GMT) |
commit | 82208ae074ac93ecebefb924402d1dc992a72432 (patch) | |
tree | bb90d355e37e685906cc50cf684aa34b316d3be8 /win | |
parent | cced21f712893036cd46da8879ba0bf48bca9c48 (diff) | |
download | tcl-82208ae074ac93ecebefb924402d1dc992a72432.zip tcl-82208ae074ac93ecebefb924402d1dc992a72432.tar.gz tcl-82208ae074ac93ecebefb924402d1dc992a72432.tar.bz2 |
2001-01-04 Don Porter <dgp@users.sourceforge.net>
* tests/unixInit.test:
* unix/tclUnixInit.c (TclpInitLibraryPath):
* win/tclWinInit.c (TclpInitLibraryPath): Several entries in
the library path ($tcl_libPath) are determined relative to the
absolute path of the executable. When the executable is
installed in or near the root directory of the file system,
relative pathnames were being incorrectly generated, and in
the worst case, memory access violations were crashing the program.
[Bug 119416, Patch 102972]
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinInit.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 1f6d76f..125afcc 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.24 2000/07/26 01:27:58 davidg Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.25 2001/01/04 21:30:49 dgp Exp $ */ #include "tclWinInt.h" @@ -229,44 +229,49 @@ TclpInitLibraryPath(path) * (e.g. /usr/src/tcl8.2/unix/solaris-sparc/../../../tcl8.2/library) */ + /* + * The variable path holds an absolute path. Take care not to + * overwrite pathv[0] since that might produce a relative path. + */ + if (path != NULL) { Tcl_SplitPath(path, &pathc, &pathv); - if (pathc > 1) { + if (pathc > 2) { pathv[pathc - 2] = installLib; path = Tcl_JoinPath(pathc - 1, pathv, &ds); objPtr = Tcl_NewStringObj(path, Tcl_DStringLength(&ds)); Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } - if (pathc > 2) { + if (pathc > 3) { pathv[pathc - 3] = installLib; path = Tcl_JoinPath(pathc - 2, pathv, &ds); objPtr = Tcl_NewStringObj(path, Tcl_DStringLength(&ds)); Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } - if (pathc > 1) { + if (pathc > 2) { pathv[pathc - 2] = "library"; path = Tcl_JoinPath(pathc - 1, pathv, &ds); objPtr = Tcl_NewStringObj(path, Tcl_DStringLength(&ds)); Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } - if (pathc > 2) { + if (pathc > 3) { pathv[pathc - 3] = "library"; path = Tcl_JoinPath(pathc - 2, pathv, &ds); objPtr = Tcl_NewStringObj(path, Tcl_DStringLength(&ds)); Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } - if (pathc > 1) { + if (pathc > 3) { pathv[pathc - 3] = developLib; path = Tcl_JoinPath(pathc - 2, pathv, &ds); objPtr = Tcl_NewStringObj(path, Tcl_DStringLength(&ds)); Tcl_ListObjAppendElement(NULL, pathPtr, objPtr); Tcl_DStringFree(&ds); } - if (pathc > 3) { + if (pathc > 4) { pathv[pathc - 4] = developLib; path = Tcl_JoinPath(pathc - 3, pathv, &ds); objPtr = Tcl_NewStringObj(path, Tcl_DStringLength(&ds)); |