diff options
author | dgp <dgp@users.sourceforge.net> | 2004-10-06 15:59:22 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2004-10-06 15:59:22 (GMT) |
commit | b0e29724338467351f10a4b11e317a5866ac658f (patch) | |
tree | d861bb4c44fd414c034f6faa23c736648d498e29 /generic/tclIO.c | |
parent | a57d7ac68eaafc7de2e3f9d05a148384f3716f52 (diff) | |
download | tcl-b0e29724338467351f10a4b11e317a5866ac658f.zip tcl-b0e29724338467351f10a4b11e317a5866ac658f.tar.gz tcl-b0e29724338467351f10a4b11e317a5866ac658f.tar.bz2 |
* generic/tclBasic.c:
* generic/tclBinary.c:
* generic/tclCmdAH.c:
* generic/tclCmdIL.c:
* generic/tclCmdMZ.c:
* generic/tclCompExpr.c:
* generic/tclDictObj.c:
* generic/tclEncoding.c:
* generic/tclExecute.c:
* generic/tclFCmd.c:
* generic/tclHistory.c:
* generic/tclIndexObj.c:
* generic/tclInterp.c:
* generic/tclIO.c:
* generic/tclIOCmd.c:
* generic/tclNamesp.c:
* generic/tclObj.c:
* generic/tclPkg.c:
* generic/tclResult.c:
* generic/tclScan.c:
* generic/tclTimer.c:
* generic/tclTrace.c:
* generic/tclUtil.c:
* generic/tclVar.c:
It is a poor practice to directly set or append to the value
of the objResult of an interp, because that value might be
shared, and in that circumstance a Tcl_Panic() will be the
result. Searched for example of this practice and replaced
with safer alternatives, often using the Tcl_AppendResult()
routine that dkf just rehabilitated.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 13630ac..ca1c868 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.78 2004/09/10 20:04:10 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.79 2004/10/06 15:59:23 dgp Exp $ */ #include "tclInt.h" @@ -7567,12 +7567,12 @@ TclCopyChannel(interp, inChan, outChan, toRead, cmdPtr) outStatePtr = outPtr->state; if (inStatePtr->csPtr) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", + Tcl_AppendResult(interp, "channel \"", Tcl_GetChannelName(inChan), "\" is busy", NULL); return TCL_ERROR; } if (outStatePtr->csPtr) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", + Tcl_AppendResult(interp, "channel \"", Tcl_GetChannelName(outChan), "\" is busy", NULL); return TCL_ERROR; } @@ -7904,7 +7904,7 @@ CopyData(csPtr, mask) result = TCL_ERROR; } else { Tcl_ResetResult(interp); - Tcl_SetIntObj(Tcl_GetObjResult(interp), total); + Tcl_SetObjResult(interp, Tcl_NewIntObj(total)); } } return result; @@ -8721,7 +8721,7 @@ Tcl_GetChannelNamesEx(interp, pattern) * for this interpreter. */ hTblPtr = GetChannelTable(interp); - resultPtr = Tcl_GetObjResult(interp); + resultPtr = Tcl_NewObj(); for (hPtr = Tcl_FirstHashEntry(hTblPtr, &hSearch); hPtr != (Tcl_HashEntry *) NULL; @@ -8745,9 +8745,11 @@ Tcl_GetChannelNamesEx(interp, pattern) if (((pattern == NULL) || Tcl_StringMatch(name, pattern)) && (Tcl_ListObjAppendElement(interp, resultPtr, Tcl_NewStringObj(name, -1)) != TCL_OK)) { + Tcl_DecrRefCount(resultPtr); return TCL_ERROR; } } + Tcl_SetObjResult(interp, resultPtr); return TCL_OK; } |