From ac3a9b43fdb9eab96727dbf392aa04f2b81ebd51 Mon Sep 17 00:00:00 2001 From: dkf Date: Sat, 30 Jun 2007 14:07:50 +0000 Subject: Plug a memory leak caused by a missing Tcl_DecrRefCount on an error path. [Bug 1717186] --- ChangeLog | 51 ++++++++++++++++++++++++++++----------------------- generic/tclCmdIL.c | 20 +++++++++++--------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60355f3..e58cfa5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,13 @@ +2007-06-30 Donal K. Fellows + + * generic/tclCmdIL.c (Tcl_LsortObjCmd): Plug a memory leak caused by + a missing Tcl_DecrRefCount on an error path. [Bug 1717186] + 2007-06-30 Zoran Vasiljevic * generic/tclThread.c: Prevent RemeberSyncObj() from growing the sync - object lists by reusing already free'd slots, if possible. - See discussion on Bug 1726873 for more information. + object lists by reusing already free'd slots, if possible. See + discussion on Bug 1726873 for more information. 2007-06-29 Donal K. Fellows @@ -42,12 +47,12 @@ 2007-06-28 Pat Thoyts - * generic/tclBasic.c: Silence constness warnings for - * generic/tclCompCmds.c: TclStackFree when building with msvc. + * generic/tclBasic.c: Silence constness warnings for TclStackFree + * generic/tclCompCmds.c: when building with msvc. * generic/tclFCmd.c: * generic/tclIOCmd.c: * generic/tclTrace.c: - + 2007-06-28 Miguel Sofer * generic/tclVar.c (UnsetVarStruct): fix possible segfault. @@ -61,8 +66,8 @@ 2007-06-26 Don Porter - * generic/tclBasic.c (TclEvalEx): Moved some arrays from the - C stack to the Tcl stack. + * generic/tclBasic.c (TclEvalEx): Moved some arrays from the C + stack to the Tcl stack. 2007-06-26 Miguel Sofer @@ -81,10 +86,10 @@ 2007-06-24 Miguel Sofer - * generic/tclVar.c (TclDeleteCompiledLocalVars): removed inlining - that ended up not really optimising (limited benchmarks). Now - calling UnsetVarStruct (streamlined old code is #ifdef'ed out, in - case better benchmarks do show a difference). + * generic/tclVar.c (TclDeleteCompiledLocalVars): removed inlining that + ended up not really optimising (limited benchmarks). Now calling + UnsetVarStruct (streamlined old code is #ifdef'ed out, in case better + benchmarks do show a difference). * generic/tclVar.c (UnsetVarStruct): fixed a leak introduced in last commit. @@ -94,7 +99,7 @@ * generic/tclVar.c (UnsetVarStruct, TclDeleteVars): made the logic slightly clearer, eliminated some duplicated code. - *** POTENTIAL INCOMPATIBILITY *** (tclInt.h and Var struct users) + *** POTENTIAL INCOMPATIBILITY *** (tclInt.h and Var struct users) The core never builds VAR_LINK variable to have traces. Such a "monster", should one exist, will now have its unset traces called *before* it is unlinked. @@ -118,16 +123,16 @@ 2007-06-21 Don Porter * generic/tclBasic.c: Move most instances of the Tcl_Parse struct - * generic/tclCompExpr.c: off the C stack and onto the Tcl stack. - * generic/tclCompile.c: This is a rather large struct (> 3kB). + * generic/tclCompExpr.c: off the C stack and onto the Tcl stack. This + * generic/tclCompile.c: is a rather large struct (> 3kB). * generic/tclParse.c: 2007-06-21 Miguel Sofer - * generic/tclBasic.c (TEOvI): Made sure that leave - * generic/tclExecute.c (INST_INVOKE): traces that were created - * tests/trace.test (trace-36.2): during execution of an - originally untraced command do not fire [Bug 1740962], partial fix. + * generic/tclBasic.c (TEOvI): Made sure that leave traces + * generic/tclExecute.c (INST_INVOKE): that were created during + * tests/trace.test (trace-36.2): execution of an originally + untraced command do not fire [Bug 1740962], partial fix. 2007-06-21 Donal K. Fellows @@ -186,13 +191,13 @@ * generic/tclProc.c (Tcl_ProcObjCmd, SetLambdaFromAny): Moved the CmdFrame off the C stack and onto the Tcl stack. - * generic/tclExecute.c (TEBC): Moved the CmdFrame off the C stack - and onto the Tcl stack, between the catch and the execution stacks - + * generic/tclExecute.c (TEBC): Moved the CmdFrame off the C stack and + onto the Tcl stack, between the catch and the execution stacks + 2007-06-18 Don Porter - * generic/tclBasic.c (TclEvalEx,TclEvalObjEx): Moved the CmdFrame - off the C stack and onto the Tcl stack. + * generic/tclBasic.c (TclEvalEx,TclEvalObjEx): Moved the CmdFrame off + the C stack and onto the Tcl stack. 2007-06-17 Donal K. Fellows diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 702bdca..69f8a67 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdIL.c,v 1.119 2007/06/22 20:42:23 dgp Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.120 2007/06/30 14:07:50 dkf Exp $ */ #include "tclInt.h" @@ -1188,7 +1188,8 @@ InfoFrameCmd( * Execution of bytecode. Talk to the BC engine to fill out the frame. */ - Proc *procPtr = framePtr->framePtr ? framePtr->framePtr->procPtr : NULL; + Proc *procPtr = + framePtr->framePtr ? framePtr->framePtr->procPtr : NULL; CmdFrame *fPtr; fPtr = (CmdFrame *) TclStackAlloc(interp, sizeof(CmdFrame)); @@ -1197,7 +1198,6 @@ InfoFrameCmd( /* * Note: * Type BC => f.data.eval.path is not used. - * f.data.tebc.codePtr is used instead. */ @@ -1221,7 +1221,8 @@ InfoFrameCmd( Tcl_DecrRefCount(fPtr->data.eval.path); } - ADD_PAIR("cmd", Tcl_NewStringObj(fPtr->cmd.str.cmd, fPtr->cmd.str.len)); + ADD_PAIR("cmd", + Tcl_NewStringObj(fPtr->cmd.str.cmd, fPtr->cmd.str.len)); if (procPtr != NULL) { Tcl_HashEntry *namePtr = procPtr->cmdPtr->hPtr; @@ -3991,7 +3992,7 @@ Tcl_LsortObjCmd( * 1675116] */ - listObj = TclListObjCopy(interp,listObj); + listObj = TclListObjCopy(interp, listObj); if (listObj == NULL) { if (sortInfo.indexc > 1) { ckfree((char *) sortInfo.indexv); @@ -4009,9 +4010,10 @@ Tcl_LsortObjCmd( Tcl_IncrRefCount(newCommandPtr); if (Tcl_ListObjAppendElement(interp, newCommandPtr, newObjPtr) != TCL_OK) { - Tcl_DecrRefCount(newCommandPtr); + TclDecrRefCount(newCommandPtr); + TclDecrRefCount(listObj) Tcl_IncrRefCount(newObjPtr); - Tcl_DecrRefCount(newObjPtr); + TclDecrRefCount(newObjPtr); if (sortInfo.indexc > 1) { ckfree((char *) sortInfo.indexv); } @@ -4070,8 +4072,8 @@ Tcl_LsortObjCmd( done: if (sortInfo.sortMode == SORTMODE_COMMAND) { - Tcl_DecrRefCount(sortInfo.compareCmdPtr); - Tcl_DecrRefCount(listObj); + TclDecrRefCount(sortInfo.compareCmdPtr); + TclDecrRefCount(listObj); sortInfo.compareCmdPtr = NULL; } if (sortInfo.indexc > 1) { -- cgit v0.12