$OpenBSD: patch-tcl_tclProc_c,v 1.1 2001/05/14 16:42:55 millert Exp $ --- tcl/tclProc.c.orig Fri Feb 24 14:19:56 1995 +++ tcl/tclProc.c Mon May 14 10:33:04 2001 @@ -124,8 +124,8 @@ Tcl_ProcCmd(dummy, interp, argc, argv) argPtr = (Var *) malloc(VAR_SIZE(nameLength, valueLength)); procPtr->argPtr = argPtr; } else { - argPtr->nextPtr = (Var *) malloc(VAR_SIZE(nameLength, valueLength)); - argPtr = argPtr->nextPtr; + procPtr->argPtr->nextPtr = (Var *) malloc(VAR_SIZE(nameLength, valueLength)); + argPtr = procPtr->argPtr->nextPtr; } strcpy(argPtr->name, fieldValues[0]); if (fieldCount == 2) { @@ -136,6 +136,7 @@ Tcl_ProcCmd(dummy, interp, argc, argv) } argPtr->valueLength = valueLength; argPtr->flags = 0; + argPtr->globalPtr = NULL; argPtr->nextPtr = NULL; free((char *) fieldValues); } @@ -793,11 +794,13 @@ InterpProc(procPtr, interp, argc, argv) */ procDone: - for (argPtr = frame.varPtr; argPtr != NULL; argPtr = argPtr->nextPtr) { + for (argPtr = frame.varPtr; argPtr != NULL;) { + void *tmp = argPtr; if (argPtr->flags & VAR_DYNAMIC) { free(argPtr->value); } - free((char *) argPtr); + argPtr = argPtr->nextPtr; + free(tmp); } iPtr->framePtr = frame.callerPtr; iPtr->varFramePtr = frame.callerVarPtr; @@ -826,13 +829,14 @@ void ProcDeleteProc(procPtr) register Proc *procPtr; /* Procedure to be deleted. */ { - register Var *argPtr; + register Var *argPtr, *arg1Ptr; free((char *) procPtr->command); - for (argPtr = procPtr->argPtr; argPtr != NULL; argPtr = argPtr->nextPtr) { + for (argPtr = procPtr->argPtr; argPtr != NULL; argPtr = arg1Ptr) { if (argPtr->flags & VAR_DYNAMIC) { free(argPtr->value); } + arg1Ptr = argPtr->nextPtr; free((char *) argPtr); } free((char *) procPtr);