summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2008-06-24 20:02:25 (GMT)
committerdgp <dgp@users.sourceforge.net>2008-06-24 20:02:25 (GMT)
commit19248ae9508b2b39a265b8107590fe628cbbae7f (patch)
tree1c7c557af4abac75395c45a952a64f0236a9ac4e
parentd71d99fe46ff7df438501ced7d8e53a3bcd4dca3 (diff)
downloadtcl-19248ae9508b2b39a265b8107590fe628cbbae7f.zip
tcl-19248ae9508b2b39a265b8107590fe628cbbae7f.tar.gz
tcl-19248ae9508b2b39a265b8107590fe628cbbae7f.tar.bz2
* generic/tclPathObj.c: Fixed some internals management in the "path"
Tcl_ObjType for the empty string value. Problem led to a crash in the command [glob -dir {} a]. [Bug 1999176].
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclPathObj.c27
2 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f90c797..6b9dbbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-24 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclPathObj.c: Fixed some internals management in the "path"
+ Tcl_ObjType for the empty string value. Problem led to a crash in
+ the command [glob -dir {} a]. [Bug 1999176].
+
2008-06-24 Pat Thoyts <patthoyts@users.sourceforge.net>
* doc/fileevent.n: bug #1995063 fix examples and comment on eof use.
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index f292c8a..c41aafc 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPathObj.c,v 1.69 2008/06/23 15:34:15 dgp Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.70 2008/06/24 20:02:31 dgp Exp $
*/
#include "tclInt.h"
@@ -1768,6 +1768,16 @@ Tcl_FSGetNormalizedPath(
if (pathType == TCL_PATH_RELATIVE) {
Tcl_Obj *origDir = fsPathPtr->cwdPtr;
+
+ /*
+ * NOTE: here we are (dangerously?) assuming that origDir points
+ * to a Tcl_Obj with Tcl_ObjType == &tclFsPathType . The
+ * pathType = Tcl_FSGetPathType(fsPathPtr->cwdPtr);
+ * above that set the pathType value should have established
+ * that, but it's far less clear on what basis we know there's
+ * been no shimmering since then.
+ */
+
FsPath *origDirFsPathPtr = PATHOBJ(origDir);
fsPathPtr->cwdPtr = origDirFsPathPtr->cwdPtr;
@@ -1881,7 +1891,20 @@ Tcl_FSGetNormalizedPath(
* might loop back through here.
*/
- if (path[0] != '\0') {
+ if (path[0] == '\0') {
+ /*
+ * Special handling for the empty string value. This one is
+ * very weird with [file normalize {}] => {}. (The reasoning
+ * supporting this is unknown to DGP, but he fears changing it.)
+ * Attempt here to keep the expectations of other parts of
+ * Tcl_Filesystem code about state of the FsPath fields satisfied.
+ *
+ * In particular, capture the cwd value and save so it can be
+ * stored in the cwdPtr field below.
+ */
+ useThisCwd = Tcl_FSGetCwd(interp);
+
+ } else {
/*
* We don't ask for the type of 'pathPtr' here, because that is
* not correct for our purposes when we have a path like '~'. Tcl