diff options
Diffstat (limited to 'generic')
-rwxr-xr-x | generic/tclArithSeries.c | 6 | ||||
-rw-r--r-- | generic/tclExecute.c | 4 | ||||
-rw-r--r-- | generic/tclTestABSList.c | 9 | ||||
-rw-r--r-- | generic/tclTestObj.c | 2 |
4 files changed, 13 insertions, 8 deletions
diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index b6ea45b..415c85a 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -610,7 +610,7 @@ TclArithSeriesObjIndex( ArithSeries *arithSeriesRepPtr = ArithSeriesGetInternalRep(arithSeriesObj); if (index < 0 || arithSeriesRepPtr->len <= index) { - *elemObj = Tcl_NewObj(); + *elemObj = NULL; } else { /* List[i] = Start + (Step * index) */ if (arithSeriesRepPtr->isDouble) { @@ -1183,8 +1183,8 @@ ArithSeriesInOperation( Tcl_Obj *elemObj; index = (y - intRepPtr->start) / intRepPtr->step; TclArithSeriesObjIndex(interp, arithSeriesObjPtr, index, &elemObj); - char *vstr = Tcl_GetStringFromObj(valueObj, &vlen); - char *estr = Tcl_GetStringFromObj(elemObj, &elen); + char const *vstr = Tcl_GetStringFromObj(valueObj, &vlen); + char const *estr = elemObj ? Tcl_GetStringFromObj(elemObj, &elen) : ""; if (boolResult) { *boolResult = (elen == vlen) ? (memcmp(estr, vstr, elen) == 0) : 0; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 38a598f..5ece319 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -4692,6 +4692,10 @@ TEBCresume( goto gotError; } CACHE_STACK_INFO(); + if (objResultPtr == NULL) { + /* Index is out of range, return empty result. */ + TclNewObj(objResultPtr); + } Tcl_IncrRefCount(objResultPtr); // reference held here goto lindexDone; } diff --git a/generic/tclTestABSList.c b/generic/tclTestABSList.c index 4795ef6..227d1b6 100644 --- a/generic/tclTestABSList.c +++ b/generic/tclTestABSList.c @@ -274,7 +274,7 @@ my_LStringObjIndex( cchar[1] = 0; *charObjPtr = Tcl_NewStringObj(cchar,1); } else { - *charObjPtr = Tcl_NewObj(); + *charObjPtr = NULL; } return TCL_OK; @@ -1015,9 +1015,10 @@ lgenSeriesObjIndex( lgenSeriesRepPtr = (LgenSeries*)lgenSeriesObjPtr->internalRep.twoPtrValue.ptr1; - if (index < 0 || index >= lgenSeriesRepPtr->len) - return TCL_ERROR; - + if (index < 0 || index >= lgenSeriesRepPtr->len) { + *elemPtr = NULL; + return TCL_OK; + } if (lgenSeriesRepPtr->interp == NULL && interp == NULL) { return TCL_ERROR; } diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c index 70c75b6..6a0d47d 100644 --- a/generic/tclTestObj.c +++ b/generic/tclTestObj.c @@ -1073,7 +1073,7 @@ static const Tcl_ObjType v1TestListType = { offsetof(Tcl_ObjType, indexProc), /* This is a V1 objType, which doesn't have an indexProc */ V1TestListObjLength, /* always return 100, doesn't really matter */ V1TestListObjIndex, /* should never be accessed, because this objType = V1*/ - NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL }; |