summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-02-28 17:08:43 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-02-28 17:08:43 (GMT)
commit09ea3ba2caab70f7b890d3ad5198a6b500e0f313 (patch)
tree5194f377c644e8dde41bf11a2b5f0c7387f1e569
parent0fa1988fb066d34703a742b0888957da882ba2e4 (diff)
downloadtcl-09ea3ba2caab70f7b890d3ad5198a6b500e0f313.zip
tcl-09ea3ba2caab70f7b890d3ad5198a6b500e0f313.tar.gz
tcl-09ea3ba2caab70f7b890d3ad5198a6b500e0f313.tar.bz2
Revise TclReleaseLiteral() to tolerate a NULL interp argument.
Update callers and revise mistaken comments.
-rw-r--r--ChangeLog8
-rw-r--r--generic/tclCompile.c16
-rw-r--r--generic/tclLiteral.c8
-rw-r--r--generic/tclProc.c12
4 files changed, 21 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 7bffb3e..696c2a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2013-02-28 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclLiteral.c: Revise TclReleaseLiteral() to tolerate a
+ NULL interp argument.
+
+ * generic/tclCompile.c: Update callers and revise mistaken comments.
+ * generic/tclProc.c:
+
2013-02-27 Jan Nijtmans <nijtmans@users.sf.net>
* generic/regcomp.c: [Bug 3606139]: missing error check allows
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 91eab6e..cf165f6 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.c
@@ -918,7 +918,7 @@ TclCleanupByteCode(
* released.
*/
- if ((codePtr->flags & TCL_BYTECODE_PRECOMPILED) || (interp == NULL)) {
+ if (codePtr->flags & TCL_BYTECODE_PRECOMPILED) {
objArrayPtr = codePtr->objArrayPtr;
for (i = 0; i < numLitObjects; i++) {
@@ -931,17 +931,9 @@ TclCleanupByteCode(
codePtr->numLitObjects = 0;
} else {
objArrayPtr = codePtr->objArrayPtr;
- for (i = 0; i < numLitObjects; i++) {
- /*
- * TclReleaseLiteral sets a ByteCode's object array entry NULL to
- * indicate that it has already freed the literal.
- */
-
- objPtr = *objArrayPtr;
- if (objPtr != NULL) {
- TclReleaseLiteral(interp, objPtr);
- }
- objArrayPtr++;
+ while (numLitObjects--) {
+ /* TclReleaseLiteral calls Tcl_DecrRefCount() for us */
+ TclReleaseLiteral(interp, *objArrayPtr++);
}
}
diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c
index 441ea91..2cba18d 100644
--- a/generic/tclLiteral.c
+++ b/generic/tclLiteral.c
@@ -750,11 +750,16 @@ TclReleaseLiteral(
* TclRegisterLiteral. */
{
Interp *iPtr = (Interp *) interp;
- LiteralTable *globalTablePtr = &iPtr->literalTable;
+ LiteralTable *globalTablePtr;
register LiteralEntry *entryPtr, *prevPtr;
const char *bytes;
int length, index;
+ if (iPtr == NULL) {
+ goto done;
+ }
+
+ globalTablePtr = &iPtr->literalTable;
bytes = TclGetStringFromObj(objPtr, &length);
index = (HashString(bytes, length) & globalTablePtr->mask);
@@ -798,6 +803,7 @@ TclReleaseLiteral(
* Remove the reference corresponding to the local literal table entry.
*/
+ done:
Tcl_DecrRefCount(objPtr);
}
diff --git a/generic/tclProc.c b/generic/tclProc.c
index e66b8ea..13f6f8a 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -1347,17 +1347,9 @@ TclFreeLocalCache(
for (i = 0; i < localCachePtr->numVars; i++, namePtrPtr++) {
register Tcl_Obj *objPtr = *namePtrPtr;
- /*
- * Note that this can be called with interp==NULL, on interp deletion.
- * In that case, the literal table and objects go away on their own.
- */
-
if (objPtr) {
- if (interp) {
- TclReleaseLiteral(interp, objPtr);
- } else {
- Tcl_DecrRefCount(objPtr);
- }
+ /* TclReleaseLiteral calls Tcl_DecrRefCount for us */
+ TclReleaseLiteral(interp, objPtr);
}
}
ckfree(localCachePtr);