summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-11-26 17:00:55 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-11-26 17:00:55 (GMT)
commitf12dc54f7578abc9e2d5f625157263ec5a0bc40e (patch)
tree3e5190c1f6bf7c11a84c866357e5321453acf71b
parent63678d528b5d4384d8a6fd8941b73888399227e5 (diff)
downloadtcl-f12dc54f7578abc9e2d5f625157263ec5a0bc40e.zip
tcl-f12dc54f7578abc9e2d5f625157263ec5a0bc40e.tar.gz
tcl-f12dc54f7578abc9e2d5f625157263ec5a0bc40e.tar.bz2
Same issue in expr parser also tested and fixed.
-rw-r--r--generic/tclCompExpr.c32
-rw-r--r--tests/parseExpr.test6
2 files changed, 18 insertions, 20 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 9142e2b..dde4e56 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -1969,31 +1969,23 @@ ParseLexeme(
}
}
- if (Tcl_UtfCharComplete(start, numBytes)) {
- scanned = Tcl_UtfToUniChar(start, &ch);
- } else {
- char utfBytes[TCL_UTF_MAX];
- memcpy(utfBytes, start, (size_t) numBytes);
- utfBytes[numBytes] = '\0';
- scanned = Tcl_UtfToUniChar(utfBytes, &ch);
- }
- if (!isalnum(UCHAR(ch))) {
- *lexemePtr = INVALID;
- Tcl_DecrRefCount(literal);
- return scanned;
- }
- end = start;
- while (isalnum(UCHAR(ch)) || (UCHAR(ch) == '_')) {
- end += scanned;
- numBytes -= scanned;
- if (Tcl_UtfCharComplete(end, numBytes)) {
- scanned = Tcl_UtfToUniChar(end, &ch);
+ if (!isalnum(UCHAR(*start))) {
+ if (Tcl_UtfCharComplete(start, numBytes)) {
+ scanned = Tcl_UtfToUniChar(start, &ch);
} else {
char utfBytes[TCL_UTF_MAX];
- memcpy(utfBytes, end, (size_t) numBytes);
+ memcpy(utfBytes, start, (size_t) numBytes);
utfBytes[numBytes] = '\0';
scanned = Tcl_UtfToUniChar(utfBytes, &ch);
}
+ *lexemePtr = INVALID;
+ Tcl_DecrRefCount(literal);
+ return scanned;
+ }
+ end = start;
+ while (numBytes && (isalnum(UCHAR(*end)) || (UCHAR(*end) == '_'))) {
+ end += 1;
+ numBytes -= 1;
}
*lexemePtr = BAREWORD;
if (literalPtr) {
diff --git a/tests/parseExpr.test b/tests/parseExpr.test
index c1c489b..3e0df29 100644
--- a/tests/parseExpr.test
+++ b/tests/parseExpr.test
@@ -1051,6 +1051,12 @@ test parseExpr-22.18 {Bug 3401704} -constraints testexprparser -body {
testexprparser 0b02 -1
} -returnCodes error -match glob -result {*invalid binary number*}
+test parseExpr-22.19 {Bug d2ffcca163} -constraints testexprparser -body {
+ testexprparser \u0433 -1
+} -returnCodes error -match glob -result {*invalid character*}
+test parseExpr-22.20 {Bug d2ffcca163} -constraints testexprparser -body {
+ testexprparser \u043f -1
+} -returnCodes error -match glob -result {*invalid character*}
# cleanup
cleanupTests