diff options
author | stanton <stanton> | 1998-10-06 00:36:56 (GMT) |
---|---|---|
committer | stanton <stanton> | 1998-10-06 00:36:56 (GMT) |
commit | 07cabd057d663dc04f253f622389a6612b9144f6 (patch) | |
tree | 73a6bb72354ff9977c05d8f0c36f739a681f525f | |
parent | 131dfa93542f43a3dce6378ab36d454e03c2c3f6 (diff) | |
download | tcl-07cabd057d663dc04f253f622389a6612b9144f6.zip tcl-07cabd057d663dc04f253f622389a6612b9144f6.tar.gz tcl-07cabd057d663dc04f253f622389a6612b9144f6.tar.bz2 |
* tclFileName.c: added warnings around code that modifies strings in place
-rw-r--r-- | generic/tclFileName.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 13427fc..01fefa7 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFileName.c,v 1.1.2.2 1998/09/24 23:58:49 stanton Exp $ + * RCS: @(#) $Id: tclFileName.c,v 1.1.2.3 1998/10/06 00:36:56 stanton Exp $ */ #include "tclInt.h" @@ -1263,7 +1263,8 @@ int TclGlob(interp, pattern, noComplain) Tcl_Interp *interp; /* Interpreter for returning error message * or appending list of matching file names. */ - char *pattern; /* Glob pattern to match. */ + char *pattern; /* Glob pattern to match. Must not refer + * to a static string. */ int noComplain; /* Flag to turn off storing error messages * in interp. */ { @@ -1446,7 +1447,8 @@ TclDoGlob(interp, separators, headPtr, tail) * that should be used to identify globbing * boundaries. */ Tcl_DString *headPtr; /* Completely expanded prefix. */ - char *tail; /* The unexpanded remainder of the path. */ + char *tail; /* The unexpanded remainder of the path. + * Must not be a pointer to a static string. */ { int baseLength, quoted, count; int result = TCL_OK; @@ -1622,6 +1624,12 @@ TclDoGlob(interp, separators, headPtr, tail) */ if (*p != '\0') { + + /* + * Note that we are modifying the string in place. This won't work + * if the string is a static. + */ + savedChar = *p; *p = '\0'; firstSpecialChar = strpbrk(tail, "*[]?\\"); |