From dbbd3ddbdbf2849591a911e6f3c0919d1e42072a Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 16 Sep 2010 09:43:17 +1000 Subject: It was possible to create a bad ref Need to fix invalid chars in the tag name Signed-off-by: Steve Bennett --- jim.c | 4 ++-- regtest.tcl | 6 ++++++ 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 ---" -- cgit v1.1