summaryrefslogtreecommitdiffstats
path: root/generic/tclProc.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2012-06-11 17:34:35 (GMT)
committerdgp <dgp@users.sourceforge.net>2012-06-11 17:34:35 (GMT)
commit45d29cd41c215484eaf33a4f02be315a6b1872b9 (patch)
tree13f169828086bfbd8f44e7b6e5c8253d26bc58f3 /generic/tclProc.c
parent7e302d3ca75cd9eb6998e895cf344665b1d08e5e (diff)
parent2c0667d7b04e34fa929ccc4758a19af166cf4206 (diff)
downloadtcl-45d29cd41c215484eaf33a4f02be315a6b1872b9.zip
tcl-45d29cd41c215484eaf33a4f02be315a6b1872b9.tar.gz
tcl-45d29cd41c215484eaf33a4f02be315a6b1872b9.tar.bz2
3532959 Make sure the lifetime management of entries in the linePBodyPtr hash
table can tolerate either order of teardown, interp first, or Proc first.
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r--generic/tclProc.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 43e88c6..2c6d300 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -2198,7 +2198,7 @@ TclProcCleanupProc(
* the same ProcPtr is overwritten with a new CmdFrame.
*/
- if (!iPtr) {
+ if (iPtr == NULL) {
return;
}
@@ -2209,13 +2209,15 @@ TclProcCleanupProc(
cfPtr = (CmdFrame *) Tcl_GetHashValue(hePtr);
- if (cfPtr->type == TCL_LOCATION_SOURCE) {
- Tcl_DecrRefCount(cfPtr->data.eval.path);
- cfPtr->data.eval.path = NULL;
+ if (cfPtr) {
+ if (cfPtr->type == TCL_LOCATION_SOURCE) {
+ Tcl_DecrRefCount(cfPtr->data.eval.path);
+ cfPtr->data.eval.path = NULL;
+ }
+ ckfree((char *) cfPtr->line);
+ cfPtr->line = NULL;
+ ckfree((char *) cfPtr);
}
- ckfree((char *) cfPtr->line);
- cfPtr->line = NULL;
- ckfree((char *) cfPtr);
Tcl_DeleteHashEntry(hePtr);
}
@@ -2447,7 +2449,8 @@ SetLambdaFromAny(
Interp *iPtr = (Interp *) interp;
char *name;
Tcl_Obj *argsPtr, *bodyPtr, *nsObjPtr, **objv, *errPtr;
- int objc, result;
+ int isNew, objc, result;
+ CmdFrame *cfPtr = NULL;
Proc *procPtr;
if (interp == NULL) {
@@ -2544,14 +2547,14 @@ SetLambdaFromAny(
if (contextPtr->line
&& (contextPtr->nline >= 2) && (contextPtr->line[1] >= 0)) {
- int isNew, buf[2];
- CmdFrame *cfPtr = (CmdFrame *) ckalloc(sizeof(CmdFrame));
+ int buf[2];
/*
* Move from approximation (line of list cmd word) to actual
* location (line of 2nd list element).
*/
+ cfPtr = (CmdFrame *) ckalloc(sizeof(CmdFrame));
TclListLines(objPtr, contextPtr->line[1], 2, buf, NULL);
cfPtr->level = -1;
@@ -2567,9 +2570,6 @@ SetLambdaFromAny(
cfPtr->cmd.str.cmd = NULL;
cfPtr->cmd.str.len = 0;
-
- Tcl_SetHashValue(Tcl_CreateHashEntry(iPtr->linePBodyPtr,
- (char *) procPtr, &isNew), cfPtr);
}
/*
@@ -2581,6 +2581,8 @@ SetLambdaFromAny(
}
TclStackFree(interp, contextPtr);
}
+ Tcl_SetHashValue(Tcl_CreateHashEntry(iPtr->linePBodyPtr, (char *) procPtr,
+ &isNew), cfPtr);
/*
* Set the namespace for this lambda: given by objv[2] understood as a