Index: generic/tclCompCmdsSZ.c ================================================================== --- generic/tclCompCmdsSZ.c +++ generic/tclCompCmdsSZ.c @@ -2838,11 +2838,11 @@ { Tcl_Size numHandlers, numWords = parsePtr->numWords; int result = TCL_ERROR, anyTrapClauses = 0; Tcl_Token *bodyToken, *finallyToken, *tokenPtr; TryHandlerInfo staticHandler, *handlers = &staticHandler; - Tcl_Size handlerIdx = 0; + Tcl_Size handlerIdx = -1; if (numWords < 2 || numWords > UINT_MAX) { return TCL_ERROR; } @@ -2862,13 +2862,15 @@ sizeof(TryHandlerInfo) * numHandlers); } else { handlers = &staticHandler; } - for (; handlerIdx < numHandlers ; handlerIdx++) { + for (handlerIdx = 0; handlerIdx < numHandlers ; handlerIdx++) { Tcl_Obj *tmpObj, **objv; Tcl_Size objc; + + handlers[handlerIdx].matchClause = NULL;/* Init for cleanup checks */ if (IS_TOKEN_LITERALLY(tokenPtr, "trap")) { /* * Parse the list of errorCode words to match against. */ @@ -3031,14 +3033,15 @@ /* * Delete any temporary state and finish off. */ failedToCompile: - while (handlerIdx-- > 0) { + while (handlerIdx >= 0) { if (handlers[handlerIdx].matchClause) { TclDecrRefCount(handlers[handlerIdx].matchClause); } + --handlerIdx; } if (handlers != &staticHandler) { TclStackFree(interp, handlers); } return result;