summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravl <avl>2017-03-02 15:24:52 (GMT)
committeravl <avl>2017-03-02 15:24:52 (GMT)
commit08737b19f8be614e48e6f8877b076ff05ad98646 (patch)
tree1ed033ae7ee360fb891724ddde7e08b8aa3c2d82
parentdd6aecfb4541cc4b0bad64cee7af6412ce88e8e8 (diff)
downloadtcl-avl_tip_282.zip
tcl-avl_tip_282.tar.gz
tcl-avl_tip_282.tar.bz2
restrictions on array index confined to lhs.avl_tip_282
-rw-r--r--generic/tclCompExpr.c2
-rw-r--r--generic/tclParse.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 6453d24..9cff125 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -746,7 +746,7 @@ ParseExpr(
const char *varend;
const char *varstart = &start[TclParseAllWhiteSpace(start, numBytes)];
int code, len;
- code = Tcl_ParseVarName(NULL, varstart, numBytes, &vparse, 0);
+ code = Tcl_ParseVarName(NULL, varstart, numBytes, &vparse, -1);
len = vparse.tokenPtr[0].size;
varend = varstart+len;
Tcl_FreeParse(&vparse);
diff --git a/generic/tclParse.c b/generic/tclParse.c
index 425b43f..7a3c55e 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -1357,10 +1357,11 @@ Tcl_ParseVarName(
* first null character. */
Tcl_Parse *parsePtr, /* Structure to fill in with information about
* the variable name. */
- int append) /* Non-zero means append tokens to existing
+ int append) /* greater-zero means append tokens to existing
* information in parsePtr; zero means ignore
- * existing tokens in parsePtr and
- * reinitialize it. */
+ * existing tokens in parsePtr and reinitialize
+ * it. less-zero means being strict and disallow
+ * un-escaped quotes, braces or open parens. */
{
Tcl_Token *tokenPtr;
register const char *src;
@@ -1374,7 +1375,7 @@ Tcl_ParseVarName(
numBytes = strlen(start);
}
- if (!append) {
+ if (append <= 0) {
TclParseInit(interp, start, numBytes, parsePtr);
}
@@ -1486,7 +1487,8 @@ Tcl_ParseVarName(
* any number of substitutions.
*/
- if (TCL_OK != TclParseTokens(src+1, numBytes-1, TYPE_BAD_ARRAY_INDEX,
+ int endFlag = (append<0) ? TYPE_BAD_ARRAY_INDEX : TYPE_CLOSE_PAREN;
+ if (TCL_OK != TclParseTokens(src+1, numBytes-1, endFlag,
TCL_SUBST_ALL, parsePtr)) {
goto error;
}