summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-02-22 18:54:56 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-02-22 18:54:56 (GMT)
commit65c016d4a09a729bfedef85021b1e73fc594adb7 (patch)
treea8c46824000b586d801a3996823062430d8ed34b /generic/tclCompile.c
parent290b2159a283b11ea45f00182d83eab1d497027b (diff)
downloadtcl-65c016d4a09a729bfedef85021b1e73fc594adb7.zip
tcl-65c016d4a09a729bfedef85021b1e73fc594adb7.tar.gz
tcl-65c016d4a09a729bfedef85021b1e73fc594adb7.tar.bz2
Restore the ReleaseCmdWordData cleanup routine from 8.4, to plug very
rare memory leak.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r--generic/tclCompile.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 357a27a..fee30bd 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -431,6 +431,7 @@ static void EnterCmdWordData(ExtCmdLoc *eclPtr, int srcOffset,
Tcl_Token *tokenPtr, const char *cmd, int len,
int numWords, int line, int* clNext, int **lines,
CompileEnv* envPtr);
+static void ReleaseCmdWordData(ExtCmdLoc *eclPtr);
/*
* The structure below defines the bytecode Tcl object type by means of
@@ -797,23 +798,7 @@ TclCleanupByteCode(
Tcl_HashEntry *hePtr = Tcl_FindHashEntry(iPtr->lineBCPtr,
(char *) codePtr);
if (hePtr) {
- ExtCmdLoc *eclPtr = Tcl_GetHashValue(hePtr);
- int i;
-
- if (eclPtr->type == TCL_LOCATION_SOURCE) {
- Tcl_DecrRefCount(eclPtr->path);
- }
- for (i=0 ; i<eclPtr->nuloc ; i++) {
- ckfree((char *) eclPtr->loc[i].line);
- }
-
- if (eclPtr->loc != NULL) {
- ckfree((char *) eclPtr->loc);
- }
-
- Tcl_DeleteHashTable (&eclPtr->litInfo);
-
- ckfree((char *) eclPtr);
+ ReleaseCmdWordData(Tcl_GetHashValue(hePtr));
Tcl_DeleteHashEntry(hePtr);
}
}
@@ -825,6 +810,28 @@ TclCleanupByteCode(
TclHandleRelease(codePtr->interpHandle);
ckfree((char *) codePtr);
}
+
+static void
+ReleaseCmdWordData(
+ ExtCmdLoc *eclPtr)
+{
+ int i;
+
+ if (eclPtr->type == TCL_LOCATION_SOURCE) {
+ Tcl_DecrRefCount(eclPtr->path);
+ }
+ for (i=0 ; i<eclPtr->nuloc ; i++) {
+ ckfree((char *) eclPtr->loc[i].line);
+ }
+
+ if (eclPtr->loc != NULL) {
+ ckfree((char *) eclPtr->loc);
+ }
+
+ Tcl_DeleteHashTable (&eclPtr->litInfo);
+
+ ckfree((char *) eclPtr);
+}
/*
*----------------------------------------------------------------------
@@ -1068,7 +1075,8 @@ TclFreeCompileEnv(
ckfree((char *) envPtr->auxDataArrayPtr);
}
if (envPtr->extCmdMapPtr) {
- ckfree((char *) envPtr->extCmdMapPtr);
+ ReleaseCmdWordData(envPtr->extCmdMapPtr);
+ envPtr->extCmdMapPtr = NULL;
}
/*