aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-09-16 09:43:17 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:52 +1000
commitdbbd3ddbdbf2849591a911e6f3c0919d1e42072a (patch)
tree4315536cd2f28a8d590bf5b49a729af90283bcf4
parentf599695f837c19be5d903e5c42097b3514ea3573 (diff)
downloadjimtcl-dbbd3ddbdbf2849591a911e6f3c0919d1e42072a.zip
jimtcl-dbbd3ddbdbf2849591a911e6f3c0919d1e42072a.tar.gz
jimtcl-dbbd3ddbdbf2849591a911e6f3c0919d1e42072a.tar.bz2
It was possible to create a bad ref
Need to fix invalid chars in the tag name Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim.c4
-rw-r--r--regtest.tcl6
2 files changed, 8 insertions, 2 deletions
diff --git a/jim.c b/jim.c
index 5949bf8..17f41f0 100644
--- a/jim.c
+++ b/jim.c
@@ -4368,13 +4368,13 @@ Jim_Obj *Jim_NewReference(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *tagPtr,
refObjPtr->internalRep.refValue.id = interp->referenceNextId;
refObjPtr->internalRep.refValue.refPtr = refPtr;
interp->referenceNextId++;
- /* Set the tag. Trimmered at JIM_REFERENCE_TAGLEN. Everything
+ /* Set the tag. Trimmed at JIM_REFERENCE_TAGLEN. Everything
* that does not pass the 'isrefchar' test is replaced with '_' */
tag = Jim_GetString(tagPtr, &tagLen);
if (tagLen > JIM_REFERENCE_TAGLEN)
tagLen = JIM_REFERENCE_TAGLEN;
for (i = 0; i < JIM_REFERENCE_TAGLEN; i++) {
- if (i < tagLen)
+ if (i < tagLen && isrefchar(tag[i]))
refPtr->tag[i] = tag[i];
else
refPtr->tag[i] = '_';
diff --git a/regtest.tcl b/regtest.tcl
index 4bfcba6..09b193e 100644
--- a/regtest.tcl
+++ b/regtest.tcl
@@ -74,6 +74,12 @@ proc a {} {{x 1}} { rename a ""; incr x }
a
puts "TEST 11 PASSED"
+# REGTEST 12
+# 13 Sep 2010 - reference with invalid tag
+set a b[ref value "tag name"]
+getref [string range $a 1 end]
+puts "TEST 12 PASSED"
+
# TAKE THE FOLLOWING puts AS LAST LINE
puts "--- ALL TESTS PASSED ---"