summaryrefslogtreecommitdiffstats
path: root/generic
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
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')
-rw-r--r--generic/tclBasic.c13
-rw-r--r--generic/tclProc.c28
2 files changed, 23 insertions, 18 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 954b2b3..fa13b50 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -1388,12 +1388,15 @@ DeleteInterpProc(
hPtr != NULL;
hPtr = Tcl_NextHashEntry(&hSearch)) {
CmdFrame *cfPtr = Tcl_GetHashValue(hPtr);
-
- if (cfPtr->type == TCL_LOCATION_SOURCE) {
- Tcl_DecrRefCount(cfPtr->data.eval.path);
+ Proc *procPtr = (Proc *) Tcl_GetHashKey(iPtr->linePBodyPtr, hPtr);
+ procPtr->iPtr = NULL;
+ if (cfPtr) {
+ if (cfPtr->type == TCL_LOCATION_SOURCE) {
+ Tcl_DecrRefCount(cfPtr->data.eval.path);
+ }
+ ckfree((char *) cfPtr->line);
+ ckfree((char *) cfPtr);
}
- ckfree((char *) cfPtr->line);
- ckfree((char *) cfPtr);
Tcl_DeleteHashEntry(hPtr);
}
Tcl_DeleteHashTable(iPtr->linePBodyPtr);
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